Saber 酱的抱枕

Fly me to the moon

04/11
2015
学习

js键盘事件处理库:keymaster.js

keymaster.js是一个小巧易用的js键盘事件处理库,不依赖于其他库。使用时只需要引入其单个文件即可。使用代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// define short of 'a'
key('a', function(){ alert('you pressed a!') });
 
// returning false stops the event and prevents default browser events
key('ctrl+r', function(){ alert('stopped reload!'); return false });
 
// multiple shortcuts
key('command+r, ctrl+r', function(){ });
 
// shortcut with a scope
key('o, enter', 'issues', function(){ /* do something */ });
key('o, enter', 'files', function(){ /* do something else */ });
key.setScope('issues'); // default scope is 'all'
 
// query modifier keys
if(key.shift) alert('shift is pressed, OMGZ!');

github主页 直接下载

js键盘事件处理库:keymaster.js

TOP
    显示公告
    聊      天
    吃 零 食
    博客后台
    生存时间
    关闭春菜
    X
    召唤春菜