Keymaster.js - 實現鍵盤快捷方式的綁定處理
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'
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!