keycodes.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. // This was copied (and slightly modified) from
  6. // devtools/shared/gcli/source/lib/gcli/util/util.js, which in turn
  7. // says:
  8. /**
  9. * Keyboard handling is a mess. http://unixpapa.com/js/key.html
  10. * It would be good to use DOM L3 Keyboard events,
  11. * http://www.w3.org/TR/2010/WD-DOM-Level-3-Events-20100907/#events-keyboardevents
  12. * however only Webkit supports them, and there isn't a shim on Modernizr:
  13. * https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills
  14. * and when the code that uses this KeyEvent was written, nothing was clear,
  15. * so instead, we're using this unmodern shim:
  16. * http://stackoverflow.com/questions/5681146/chrome-10-keyevent-or-something-similar-to-firefoxs-keyevent
  17. * See BUG 664991: GCLI's keyboard handling should be updated to use DOM-L3
  18. * https://bugzilla.mozilla.org/show_bug.cgi?id=664991
  19. */
  20. exports.KeyCodes = {
  21. DOM_VK_CANCEL: 3,
  22. DOM_VK_HELP: 6,
  23. DOM_VK_BACK_SPACE: 8,
  24. DOM_VK_TAB: 9,
  25. DOM_VK_CLEAR: 12,
  26. DOM_VK_RETURN: 13,
  27. DOM_VK_SHIFT: 16,
  28. DOM_VK_CONTROL: 17,
  29. DOM_VK_ALT: 18,
  30. DOM_VK_PAUSE: 19,
  31. DOM_VK_CAPS_LOCK: 20,
  32. DOM_VK_ESCAPE: 27,
  33. DOM_VK_SPACE: 32,
  34. DOM_VK_PAGE_UP: 33,
  35. DOM_VK_PAGE_DOWN: 34,
  36. DOM_VK_END: 35,
  37. DOM_VK_HOME: 36,
  38. DOM_VK_LEFT: 37,
  39. DOM_VK_UP: 38,
  40. DOM_VK_RIGHT: 39,
  41. DOM_VK_DOWN: 40,
  42. DOM_VK_PRINTSCREEN: 44,
  43. DOM_VK_INSERT: 45,
  44. DOM_VK_DELETE: 46,
  45. DOM_VK_0: 48,
  46. DOM_VK_1: 49,
  47. DOM_VK_2: 50,
  48. DOM_VK_3: 51,
  49. DOM_VK_4: 52,
  50. DOM_VK_5: 53,
  51. DOM_VK_6: 54,
  52. DOM_VK_7: 55,
  53. DOM_VK_8: 56,
  54. DOM_VK_9: 57,
  55. DOM_VK_SEMICOLON: 59,
  56. DOM_VK_EQUALS: 61,
  57. DOM_VK_A: 65,
  58. DOM_VK_B: 66,
  59. DOM_VK_C: 67,
  60. DOM_VK_D: 68,
  61. DOM_VK_E: 69,
  62. DOM_VK_F: 70,
  63. DOM_VK_G: 71,
  64. DOM_VK_H: 72,
  65. DOM_VK_I: 73,
  66. DOM_VK_J: 74,
  67. DOM_VK_K: 75,
  68. DOM_VK_L: 76,
  69. DOM_VK_M: 77,
  70. DOM_VK_N: 78,
  71. DOM_VK_O: 79,
  72. DOM_VK_P: 80,
  73. DOM_VK_Q: 81,
  74. DOM_VK_R: 82,
  75. DOM_VK_S: 83,
  76. DOM_VK_T: 84,
  77. DOM_VK_U: 85,
  78. DOM_VK_V: 86,
  79. DOM_VK_W: 87,
  80. DOM_VK_X: 88,
  81. DOM_VK_Y: 89,
  82. DOM_VK_Z: 90,
  83. DOM_VK_CONTEXT_MENU: 93,
  84. DOM_VK_NUMPAD0: 96,
  85. DOM_VK_NUMPAD1: 97,
  86. DOM_VK_NUMPAD2: 98,
  87. DOM_VK_NUMPAD3: 99,
  88. DOM_VK_NUMPAD4: 100,
  89. DOM_VK_NUMPAD5: 101,
  90. DOM_VK_NUMPAD6: 102,
  91. DOM_VK_NUMPAD7: 103,
  92. DOM_VK_NUMPAD8: 104,
  93. DOM_VK_NUMPAD9: 105,
  94. DOM_VK_MULTIPLY: 106,
  95. DOM_VK_ADD: 107,
  96. DOM_VK_SEPARATOR: 108,
  97. DOM_VK_SUBTRACT: 109,
  98. DOM_VK_DECIMAL: 110,
  99. DOM_VK_DIVIDE: 111,
  100. DOM_VK_F1: 112,
  101. DOM_VK_F2: 113,
  102. DOM_VK_F3: 114,
  103. DOM_VK_F4: 115,
  104. DOM_VK_F5: 116,
  105. DOM_VK_F6: 117,
  106. DOM_VK_F7: 118,
  107. DOM_VK_F8: 119,
  108. DOM_VK_F9: 120,
  109. DOM_VK_F10: 121,
  110. DOM_VK_F11: 122,
  111. DOM_VK_F12: 123,
  112. DOM_VK_F13: 124,
  113. DOM_VK_F14: 125,
  114. DOM_VK_F15: 126,
  115. DOM_VK_F16: 127,
  116. DOM_VK_F17: 128,
  117. DOM_VK_F18: 129,
  118. DOM_VK_F19: 130,
  119. DOM_VK_F20: 131,
  120. DOM_VK_F21: 132,
  121. DOM_VK_F22: 133,
  122. DOM_VK_F23: 134,
  123. DOM_VK_F24: 135,
  124. DOM_VK_NUM_LOCK: 144,
  125. DOM_VK_SCROLL_LOCK: 145,
  126. DOM_VK_COMMA: 188,
  127. DOM_VK_PERIOD: 190,
  128. DOM_VK_SLASH: 191,
  129. DOM_VK_BACK_QUOTE: 192,
  130. DOM_VK_OPEN_BRACKET: 219,
  131. DOM_VK_BACK_SLASH: 220,
  132. DOM_VK_CLOSE_BRACKET: 221,
  133. DOM_VK_QUOTE: 222,
  134. DOM_VK_META: 224,
  135. // A few that did not appear in gcli, but that are apparently used
  136. // in devtools.
  137. DOM_VK_COLON: 58,
  138. DOM_VK_VOLUME_MUTE: 181,
  139. DOM_VK_VOLUME_DOWN: 182,
  140. DOM_VK_VOLUME_UP: 183,
  141. };