JavaScript定义键盘快捷键 keymaster.js

admin 13年前
     Keymaster是一个简单,微小的JavaScript Library用于定义和调度键盘快捷键。实现没有依赖任何JavaScript框架。以下是一个使用示例:    <pre class="brush:javascript; toolbar: true; auto-links: false;">// 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!');</pre>详细信息:    <a href="/misc/goto?guid=4958188142361357769">https://github.com/madrobby/keymaster</a>    <br />