首页 > 编程语言 > 详细

Keypress - 捕获键盘输入的JavaScript库

时间:2014-05-17 14:27:21      阅读:322      评论:0      收藏:0      [点我收藏+]

 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);

  立即下载    效果演示

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!