Is there an open source library JS for keyboard binding in the browser? [closed]

假装没事ソ 提交于 2020-01-15 01:25:13

问题


I am looking to create a JavaScript app that relies heavily on keyboard shortcuts, is here a open-source library that answers those needs with cross-browser support and an easy Api?


回答1:


KeyMaster

A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.

// 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(){ });



回答2:


I recently wrote a library called mousetrap. Check it out at http://craig.is/killing/mice.

It is similar to keymaster, but also supports key sequences, international keyboard layouts, binding directly to special characters, specifying which event to listen for, etc.

It has no dependencies as well.




回答3:


Have a look at jquery.hotkeys and KeyboardJS.



来源:https://stackoverflow.com/questions/10740011/is-there-an-open-source-library-js-for-keyboard-binding-in-the-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!