Keymaster.js - 实现键盘快捷方式的绑定处理
                 jopen
                 13年前
            
                    Keymaster 是一个简单的(100行代码)的 JavaScript 库用来实现键盘快捷方式的绑定处理,无需依赖其他第三方 JS 库。
示例代码:
// 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 that do the same thing  key('⌘+r, ctrl+r', function(){ });// define shortcuts with a scope  key('o, enter', 'issues', function(){ /* do something */ });  key('o, enter', 'files', function(){ /* do something else */ });    // set the scope (only 'all' and 'issues' shortcuts will be honored)  key.setScope('issues'); // default scope is 'all'