Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* jshint esversion:6 */
- /**** Extending your module to work with MMM-KeyBindings *****
- *
- * Use the code below in your module to accept key press
- * events generated by the MMM-KeyBindings module.
- *
- * These is a basic implementation, expand as needed.
- *
- */
- var KeyHandler = Class.extend({
- /*** defaults ***
- *
- * Default Key Binding Configuration, can be overwriten on init
- *
- */
- defaults: {
- /*** MMM-KeyBindings STANDARD MAPPING ***/
- /* Add the "mode" you would like to respond to */
- mode: "DEFAULT",
- map: {
- /* Add each key you want to respond to in the form:
- * yourkeyName: "keyName_from_MMM-KeyBindings"
- */
- Right: "ArrowRight",
- Left: "ArrowLeft",
- /* ... */
- },
- /*** OPTIONAL ***/
- /* When using muliple instances (i.e. the screen connected
- * to the server & browser windows on other computers):
- *
- * multiInstance: true -- the bluetooth device will only
- * control the local server's instance.
- * The browswer windows are controlled by the local
- * keyboard (assuming enableMoustrap:true in
- * MMM-KeyBindings' config)
- *
- * multiInstance: false -- the bluetooth device will
- * control all instances of this module.
- *
- */
- multiInstance: true,
- /* If you would like your module to "take focus" when a
- * particular key is pressed change the mode
- * setting to "MYKEYWORD" and add a "takeFocus"
- * mapped to a key. This will keep other modules
- * from responding to key presses when you have focus.
- *
- * Just remember you must release focus when done!
- * Call this.releaseFocus()
- * when you're ready to release the focus.
- *
- * Additional Option:
- * For complex setups you can also set an "external interrupt"
- * in the MMM-KeyBindings config which can set the mode
- * without first sending a keypress to all modules
- *
- * Example below takes the focus when "Enter" is pressed
- *
- */
- takeFocus: "Enter",
- /* OR AS AN OBJECT: */
- // takeFocus: { keyName: "Enter", keyState: "KEY_LONGPRESSED" }
- debug: false,
- },
- /* init()
- * Is called when the module is instantiated.
- */
- init: function(name, config) {
Advertisement
Add Comment
Please, Sign In to add comment