Guest User

Config-MMM keyhandler

a guest
Mar 11th, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. /* jshint esversion:6 */
  2.  
  3. /**** Extending your module to work with MMM-KeyBindings *****
  4. *
  5. * Use the code below in your module to accept key press
  6. * events generated by the MMM-KeyBindings module.
  7. *
  8. * These is a basic implementation, expand as needed.
  9. *
  10. */
  11. var KeyHandler = Class.extend({
  12. /*** defaults ***
  13. *
  14. * Default Key Binding Configuration, can be overwriten on init
  15. *
  16. */
  17. defaults: {
  18. /*** MMM-KeyBindings STANDARD MAPPING ***/
  19. /* Add the "mode" you would like to respond to */
  20. mode: "DEFAULT",
  21. map: {
  22. /* Add each key you want to respond to in the form:
  23. * yourkeyName: "keyName_from_MMM-KeyBindings"
  24. */
  25. Right: "ArrowRight",
  26. Left: "ArrowLeft",
  27. /* ... */
  28. },
  29.  
  30. /*** OPTIONAL ***/
  31. /* When using muliple instances (i.e. the screen connected
  32. * to the server & browser windows on other computers):
  33. *
  34. * multiInstance: true -- the bluetooth device will only
  35. * control the local server's instance.
  36. * The browswer windows are controlled by the local
  37. * keyboard (assuming enableMoustrap:true in
  38. * MMM-KeyBindings' config)
  39. *
  40. * multiInstance: false -- the bluetooth device will
  41. * control all instances of this module.
  42. *
  43. */
  44. multiInstance: true,
  45.  
  46. /* If you would like your module to "take focus" when a
  47. * particular key is pressed change the mode
  48. * setting to "MYKEYWORD" and add a "takeFocus"
  49. * mapped to a key. This will keep other modules
  50. * from responding to key presses when you have focus.
  51. *
  52. * Just remember you must release focus when done!
  53. * Call this.releaseFocus()
  54. * when you're ready to release the focus.
  55. *
  56. * Additional Option:
  57. * For complex setups you can also set an "external interrupt"
  58. * in the MMM-KeyBindings config which can set the mode
  59. * without first sending a keypress to all modules
  60. *
  61. * Example below takes the focus when "Enter" is pressed
  62. *
  63. */
  64. takeFocus: "Enter",
  65. /* OR AS AN OBJECT: */
  66. // takeFocus: { keyName: "Enter", keyState: "KEY_LONGPRESSED" }
  67. debug: false,
  68. },
  69.  
  70. /* init()
  71. * Is called when the module is instantiated.
  72. */
  73. init: function(name, config) {
Advertisement
Add Comment
Please, Sign In to add comment