Keypress - 捕获键盘输入的JavaScript库

时间:2014-05-17 14:27:37   收藏:0   阅读:347

 Keypress 是一个强大的 JavaScript 库,用于捕获键盘输入。这是一个有非常特殊的功能的输入捕获库,它是很容易掌握和使用,并且不依赖第三方库。在网站开发中,经常会碰到需要处理键盘输入的场景,处理起来繁琐。现在有了这个键盘输入处理的库就很方便了。

bubuko.com,布布扣

  使用示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
keypress.combo("shift s", function() {
    console.log("You pressed shift and s");
});
 
// There are also a few other shortcut methods:
 
// If we want to register a counting combo
keypress.counting_combo("tab space", function(e, count) {
    console.log("You‘ve pressed this " + count + " times.");
});
 
// If you want to register a sequence combo
keypress.sequence_combo("up up down down left right left right b a enter", function() {
    lives = 30;
}, true);

  立即下载    效果演示

Keypress - 捕获键盘输入的JavaScript库,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!