Keyboardjs-"Build your app, I'll handle the keys"
The beautiful Life of the Sun Vulcan (http://blog.csdn.net/opengl_es)
This article follows "Attribution-non-commercial use-consistent" authoring public agreement
Reprint Please keep this sentence: Sun Vulcan's Beautiful Life-this blog focuses on Agile development and mobile and IoT device research: IOS, Android, HTML5, Arduino, Pcduino , Otherwise, the article from this blog refused to reprint or re-reproduced, thank you for your cooperation.
Keyboardjs "Build your app, I ' ll handle the keys." Democommand, Windows, Win, Super, Leftcommand, Leftwindows, Leftwin, Leftsuper, Cwhat is Keyboardjs? A JavaScript Library for binding keyboard combos without the pain of key codes and key combo conflicts. It can be used as both a standalone the library or an AMD module (see Requirejs for details). Get it heredownload keyboardjslanguage Supportkeyboardjs can support no locale, however out of the box it just comes with The US locale (for now). Adding A new locale is easy. Map your keyboard to a object and pass it to KeyboardJS.locale.register (Localename, localedefinition) then call KEYBOARDJ S.locale (Localename).
If you create a new locale consider sending me a pull request or submit it to the issue tracker so I can add it to The library. MethodsKeyboardJS.onUsageKeyboardJS.on (Keycombo, Ondowncallback, Onupcallback); Binds any key or key combo. See ' Keycombo ' definition below for details. The ondowncallback is fired once the key or key combo becomes active. The onupcallback is fired if the combo no longer active (a single key is released).
Both the Onupcallback and the Onupcallback are passed three arguments. The first is the key event, the second are the keys pressed, and the third is the key combo string. Returned
- clear () -removes the key or key combo binding.
- on () -allows you to bind to the KeyUp and KeyDown event of the given combo. An alternative to adding the Ondowncallback and Onupcallback.
KeyboardJS.activeKeysUsageKeyboardJS.activeKeys (); Returns an array of active keys by name. Returnedreturns an array of key names that is currently being pressed. KeyboardJS.clearUsageKeyboardJS.clear (Keycombo); Removes all bindings with the given key combo. See ' Keycombo ' definition for more details.
Please note this if you is just trying to remove a single binding should use the Clear method in the object returned by K Eyboardjs.on instead of this. This function was for removing the all binding, which use a certain key. KeyboardJS.clear.keyUsageKeyboardJS.clear.key (key); Removes all bindings so use the given key. KeyboardJS.localeUsageKeyboardJS.locale (Localename); Changes the locale Keyboardjs uses to map key presses. Out of the box Keyboardjs only supports US keyboards, however it was possible to add additional locales via Keyboardjs.loca Le.register () KeyboardJS.locale.registerUsageKeyboardJS.locale.register (Localename, localedefinition); Adds new locale definitions to Keyboardjs.definitionskeycomboa string containing key names separated by whitespace, >,+, and,. examples
- ' A ' -binds to the ' a ' key. Pressing ' A ' would match this keycombo.
- ' A, b '-binds to the ' a ' and ' B ' keys. Pressing either of these keys would match this keycombo.
- ' A B ' -binds to the ' a ' and ' B ' keys. Pressing either of these keys would match this keycombo.
- ' A + B ' -binds to the ' a ' and ' B ' keys. Pressing both of these keys would match this keycombo.
- ' a > B ' -binds to the ' a ' and ' B ' keys. Pressing ' A ' then ' B ' would match this keycombo.
- ' A + B, C + d ' -binds to the ' a ', ' B ', ' C ' and ' d ' keys. Pressing either the ' a ' key and the ' B ' key, or the ' C ' and the ' d ' key would match this keycombo.
- ' A + B > c + d ' -binds to the ' a ', ' B ', ' C ' and ' d ' keys. Pressing both the ' a ' key and the ' B ' key, then both the ' C ' and the ' d ' key would match this keycombo.
Localedefinitionsan object that maps keynames to their keycode and stores locale specific macros. Used for mapping keys on different locales.examples
- {"Map": {"$": ["a"], "$": ["B"], ...}, "Macros": [["Shift + '", ["tilde", "~"]], ["Shift + 1", ["exclamation", "!"] ], .... ] }
Creditsi (Robert Hurst) made this to enable better access to key controls in my applications. I ' d like-to-share it with fellow devs. Feel free to fork the This project and make your own changes.
Keyboardjs-" Build your app, I'll handle the key "