

04/11
2015
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!' ); |
这个不错,已收藏