Home Reference Source

lib/input/USKeyboardLayout.js

  1. /**
  2. * @typedef {Object} KeyDefinition
  3. * @property {number} keyCode
  4. * @property {number} shiftKeyCode
  5. * @property {string} key
  6. * @property {string} shiftKey
  7. * @property {string} code
  8. * @property {string} text
  9. * @property {string} shiftText
  10. * @property {number} location
  11. */
  12.  
  13. /**
  14. * @type {Object<string, KeyDefinition>}
  15. */
  16. module.exports = {
  17. '0': { keyCode: 48, key: '0', code: 'Digit0' },
  18. '1': { keyCode: 49, key: '1', code: 'Digit1' },
  19. '2': { keyCode: 50, key: '2', code: 'Digit2' },
  20. '3': { keyCode: 51, key: '3', code: 'Digit3' },
  21. '4': { keyCode: 52, key: '4', code: 'Digit4' },
  22. '5': { keyCode: 53, key: '5', code: 'Digit5' },
  23. '6': { keyCode: 54, key: '6', code: 'Digit6' },
  24. '7': { keyCode: 55, key: '7', code: 'Digit7' },
  25. '8': { keyCode: 56, key: '8', code: 'Digit8' },
  26. '9': { keyCode: 57, key: '9', code: 'Digit9' },
  27. Power: { key: 'Power', code: 'Power' },
  28. Eject: { key: 'Eject', code: 'Eject' },
  29. Abort: { keyCode: 3, code: 'Abort', key: 'Cancel' },
  30. Help: { keyCode: 6, code: 'Help', key: 'Help' },
  31. Backspace: { keyCode: 8, code: 'Backspace', key: 'Backspace' },
  32. Tab: { keyCode: 9, code: 'Tab', key: 'Tab' },
  33. Numpad5: {
  34. keyCode: 12,
  35. shiftKeyCode: 101,
  36. key: 'Clear',
  37. code: 'Numpad5',
  38. shiftKey: '5',
  39. location: 3
  40. },
  41. NumpadEnter: {
  42. keyCode: 13,
  43. code: 'NumpadEnter',
  44. key: 'Enter',
  45. text: '\r',
  46. location: 3
  47. },
  48. Enter: { keyCode: 13, code: 'Enter', key: 'Enter', text: '\r' },
  49. '\r': { keyCode: 13, code: 'Enter', key: 'Enter', text: '\r' },
  50. '\n': { keyCode: 13, code: 'Enter', key: 'Enter', text: '\r' },
  51. ShiftLeft: { keyCode: 16, code: 'ShiftLeft', key: 'Shift', location: 1 },
  52. ShiftRight: { keyCode: 16, code: 'ShiftRight', key: 'Shift', location: 2 },
  53. ControlLeft: {
  54. keyCode: 17,
  55. code: 'ControlLeft',
  56. key: 'Control',
  57. location: 1
  58. },
  59. ControlRight: {
  60. keyCode: 17,
  61. code: 'ControlRight',
  62. key: 'Control',
  63. location: 2
  64. },
  65. AltLeft: { keyCode: 18, code: 'AltLeft', key: 'Alt', location: 1 },
  66. AltRight: { keyCode: 18, code: 'AltRight', key: 'Alt', location: 2 },
  67. Pause: { keyCode: 19, code: 'Pause', key: 'Pause' },
  68. CapsLock: { keyCode: 20, code: 'CapsLock', key: 'CapsLock' },
  69. Escape: { keyCode: 27, code: 'Escape', key: 'Escape' },
  70. Convert: { keyCode: 28, code: 'Convert', key: 'Convert' },
  71. NonConvert: { keyCode: 29, code: 'NonConvert', key: 'NonConvert' },
  72. Space: { keyCode: 32, code: 'Space', key: ' ' },
  73. Numpad9: {
  74. keyCode: 33,
  75. shiftKeyCode: 105,
  76. key: 'PageUp',
  77. code: 'Numpad9',
  78. shiftKey: '9',
  79. location: 3
  80. },
  81. PageUp: { keyCode: 33, code: 'PageUp', key: 'PageUp' },
  82. Numpad3: {
  83. keyCode: 34,
  84. shiftKeyCode: 99,
  85. key: 'PageDown',
  86. code: 'Numpad3',
  87. shiftKey: '3',
  88. location: 3
  89. },
  90. PageDown: { keyCode: 34, code: 'PageDown', key: 'PageDown' },
  91. End: { keyCode: 35, code: 'End', key: 'End' },
  92. Numpad1: {
  93. keyCode: 35,
  94. shiftKeyCode: 97,
  95. key: 'End',
  96. code: 'Numpad1',
  97. shiftKey: '1',
  98. location: 3
  99. },
  100. Home: { keyCode: 36, code: 'Home', key: 'Home' },
  101. Numpad7: {
  102. keyCode: 36,
  103. shiftKeyCode: 103,
  104. key: 'Home',
  105. code: 'Numpad7',
  106. shiftKey: '7',
  107. location: 3
  108. },
  109. ArrowLeft: { keyCode: 37, code: 'ArrowLeft', key: 'ArrowLeft' },
  110. Numpad4: {
  111. keyCode: 37,
  112. shiftKeyCode: 100,
  113. key: 'ArrowLeft',
  114. code: 'Numpad4',
  115. shiftKey: '4',
  116. location: 3
  117. },
  118. Numpad8: {
  119. keyCode: 38,
  120. shiftKeyCode: 104,
  121. key: 'ArrowUp',
  122. code: 'Numpad8',
  123. shiftKey: '8',
  124. location: 3
  125. },
  126. ArrowUp: { keyCode: 38, code: 'ArrowUp', key: 'ArrowUp' },
  127. ArrowRight: { keyCode: 39, code: 'ArrowRight', key: 'ArrowRight' },
  128. Numpad6: {
  129. keyCode: 39,
  130. shiftKeyCode: 102,
  131. key: 'ArrowRight',
  132. code: 'Numpad6',
  133. shiftKey: '6',
  134. location: 3
  135. },
  136. Numpad2: {
  137. keyCode: 40,
  138. shiftKeyCode: 98,
  139. key: 'ArrowDown',
  140. code: 'Numpad2',
  141. shiftKey: '2',
  142. location: 3
  143. },
  144. ArrowDown: { keyCode: 40, code: 'ArrowDown', key: 'ArrowDown' },
  145. Select: { keyCode: 41, code: 'Select', key: 'Select' },
  146. Open: { keyCode: 43, code: 'Open', key: 'Execute' },
  147. PrintScreen: { keyCode: 44, code: 'PrintScreen', key: 'PrintScreen' },
  148. Insert: { keyCode: 45, code: 'Insert', key: 'Insert' },
  149. Numpad0: {
  150. keyCode: 45,
  151. shiftKeyCode: 96,
  152. key: 'Insert',
  153. code: 'Numpad0',
  154. shiftKey: '0',
  155. location: 3
  156. },
  157. Delete: { keyCode: 46, code: 'Delete', key: 'Delete' },
  158. NumpadDecimal: {
  159. keyCode: 46,
  160. shiftKeyCode: 110,
  161. code: 'NumpadDecimal',
  162. key: '\u0000',
  163. shiftKey: '.',
  164. location: 3
  165. },
  166. Digit0: { keyCode: 48, code: 'Digit0', shiftKey: ')', key: '0' },
  167. Digit1: { keyCode: 49, code: 'Digit1', shiftKey: '!', key: '1' },
  168. Digit2: { keyCode: 50, code: 'Digit2', shiftKey: '@', key: '2' },
  169. Digit3: { keyCode: 51, code: 'Digit3', shiftKey: '#', key: '3' },
  170. Digit4: { keyCode: 52, code: 'Digit4', shiftKey: '$', key: '4' },
  171. Digit5: { keyCode: 53, code: 'Digit5', shiftKey: '%', key: '5' },
  172. Digit6: { keyCode: 54, code: 'Digit6', shiftKey: '^', key: '6' },
  173. Digit7: { keyCode: 55, code: 'Digit7', shiftKey: '&', key: '7' },
  174. Digit8: { keyCode: 56, code: 'Digit8', shiftKey: '*', key: '8' },
  175. Digit9: { keyCode: 57, code: 'Digit9', shiftKey: '(', key: '9' },
  176. KeyA: { keyCode: 65, code: 'KeyA', shiftKey: 'A', key: 'a' },
  177. KeyB: { keyCode: 66, code: 'KeyB', shiftKey: 'B', key: 'b' },
  178. KeyC: { keyCode: 67, code: 'KeyC', shiftKey: 'C', key: 'c' },
  179. KeyD: { keyCode: 68, code: 'KeyD', shiftKey: 'D', key: 'd' },
  180. KeyE: { keyCode: 69, code: 'KeyE', shiftKey: 'E', key: 'e' },
  181. KeyF: { keyCode: 70, code: 'KeyF', shiftKey: 'F', key: 'f' },
  182. KeyG: { keyCode: 71, code: 'KeyG', shiftKey: 'G', key: 'g' },
  183. KeyH: { keyCode: 72, code: 'KeyH', shiftKey: 'H', key: 'h' },
  184. KeyI: { keyCode: 73, code: 'KeyI', shiftKey: 'I', key: 'i' },
  185. KeyJ: { keyCode: 74, code: 'KeyJ', shiftKey: 'J', key: 'j' },
  186. KeyK: { keyCode: 75, code: 'KeyK', shiftKey: 'K', key: 'k' },
  187. KeyL: { keyCode: 76, code: 'KeyL', shiftKey: 'L', key: 'l' },
  188. KeyM: { keyCode: 77, code: 'KeyM', shiftKey: 'M', key: 'm' },
  189. KeyN: { keyCode: 78, code: 'KeyN', shiftKey: 'N', key: 'n' },
  190. KeyO: { keyCode: 79, code: 'KeyO', shiftKey: 'O', key: 'o' },
  191. KeyP: { keyCode: 80, code: 'KeyP', shiftKey: 'P', key: 'p' },
  192. KeyQ: { keyCode: 81, code: 'KeyQ', shiftKey: 'Q', key: 'q' },
  193. KeyR: { keyCode: 82, code: 'KeyR', shiftKey: 'R', key: 'r' },
  194. KeyS: { keyCode: 83, code: 'KeyS', shiftKey: 'S', key: 's' },
  195. KeyT: { keyCode: 84, code: 'KeyT', shiftKey: 'T', key: 't' },
  196. KeyU: { keyCode: 85, code: 'KeyU', shiftKey: 'U', key: 'u' },
  197. KeyV: { keyCode: 86, code: 'KeyV', shiftKey: 'V', key: 'v' },
  198. KeyW: { keyCode: 87, code: 'KeyW', shiftKey: 'W', key: 'w' },
  199. KeyX: { keyCode: 88, code: 'KeyX', shiftKey: 'X', key: 'x' },
  200. KeyY: { keyCode: 89, code: 'KeyY', shiftKey: 'Y', key: 'y' },
  201. KeyZ: { keyCode: 90, code: 'KeyZ', shiftKey: 'Z', key: 'z' },
  202. MetaLeft: { keyCode: 91, code: 'MetaLeft', key: 'Meta', location: 1 },
  203. MetaRight: { keyCode: 92, code: 'MetaRight', key: 'Meta', location: 2 },
  204. ContextMenu: { keyCode: 93, code: 'ContextMenu', key: 'ContextMenu' },
  205. NumpadMultiply: {
  206. keyCode: 106,
  207. code: 'NumpadMultiply',
  208. key: '*',
  209. location: 3
  210. },
  211. NumpadAdd: { keyCode: 107, code: 'NumpadAdd', key: '+', location: 3 },
  212. NumpadSubtract: {
  213. keyCode: 109,
  214. code: 'NumpadSubtract',
  215. key: '-',
  216. location: 3
  217. },
  218. NumpadDivide: { keyCode: 111, code: 'NumpadDivide', key: '/', location: 3 },
  219. F1: { keyCode: 112, code: 'F1', key: 'F1' },
  220. F2: { keyCode: 113, code: 'F2', key: 'F2' },
  221. F3: { keyCode: 114, code: 'F3', key: 'F3' },
  222. F4: { keyCode: 115, code: 'F4', key: 'F4' },
  223. F5: { keyCode: 116, code: 'F5', key: 'F5' },
  224. F6: { keyCode: 117, code: 'F6', key: 'F6' },
  225. F7: { keyCode: 118, code: 'F7', key: 'F7' },
  226. F8: { keyCode: 119, code: 'F8', key: 'F8' },
  227. F9: { keyCode: 120, code: 'F9', key: 'F9' },
  228. F10: { keyCode: 121, code: 'F10', key: 'F10' },
  229. F11: { keyCode: 122, code: 'F11', key: 'F11' },
  230. F12: { keyCode: 123, code: 'F12', key: 'F12' },
  231. F13: { keyCode: 124, code: 'F13', key: 'F13' },
  232. F14: { keyCode: 125, code: 'F14', key: 'F14' },
  233. F15: { keyCode: 126, code: 'F15', key: 'F15' },
  234. F16: { keyCode: 127, code: 'F16', key: 'F16' },
  235. F17: { keyCode: 128, code: 'F17', key: 'F17' },
  236. F18: { keyCode: 129, code: 'F18', key: 'F18' },
  237. F19: { keyCode: 130, code: 'F19', key: 'F19' },
  238. F20: { keyCode: 131, code: 'F20', key: 'F20' },
  239. F21: { keyCode: 132, code: 'F21', key: 'F21' },
  240. F22: { keyCode: 133, code: 'F22', key: 'F22' },
  241. F23: { keyCode: 134, code: 'F23', key: 'F23' },
  242. F24: { keyCode: 135, code: 'F24', key: 'F24' },
  243. NumLock: { keyCode: 144, code: 'NumLock', key: 'NumLock' },
  244. ScrollLock: { keyCode: 145, code: 'ScrollLock', key: 'ScrollLock' },
  245. AudioVolumeMute: {
  246. keyCode: 173,
  247. code: 'AudioVolumeMute',
  248. key: 'AudioVolumeMute'
  249. },
  250. AudioVolumeDown: {
  251. keyCode: 174,
  252. code: 'AudioVolumeDown',
  253. key: 'AudioVolumeDown'
  254. },
  255. AudioVolumeUp: { keyCode: 175, code: 'AudioVolumeUp', key: 'AudioVolumeUp' },
  256. MediaTrackNext: {
  257. keyCode: 176,
  258. code: 'MediaTrackNext',
  259. key: 'MediaTrackNext'
  260. },
  261. MediaTrackPrevious: {
  262. keyCode: 177,
  263. code: 'MediaTrackPrevious',
  264. key: 'MediaTrackPrevious'
  265. },
  266. MediaStop: { keyCode: 178, code: 'MediaStop', key: 'MediaStop' },
  267. MediaPlayPause: {
  268. keyCode: 179,
  269. code: 'MediaPlayPause',
  270. key: 'MediaPlayPause'
  271. },
  272. Semicolon: { keyCode: 186, code: 'Semicolon', shiftKey: ':', key: ';' },
  273. Equal: { keyCode: 187, code: 'Equal', shiftKey: '+', key: '=' },
  274. NumpadEqual: { keyCode: 187, code: 'NumpadEqual', key: '=', location: 3 },
  275. Comma: { keyCode: 188, code: 'Comma', shiftKey: '<', key: ',' },
  276. Minus: { keyCode: 189, code: 'Minus', shiftKey: '_', key: '-' },
  277. Period: { keyCode: 190, code: 'Period', shiftKey: '>', key: '.' },
  278. Slash: { keyCode: 191, code: 'Slash', shiftKey: '?', key: '/' },
  279. Backquote: { keyCode: 192, code: 'Backquote', shiftKey: '~', key: '`' },
  280. BracketLeft: { keyCode: 219, code: 'BracketLeft', shiftKey: '{', key: '[' },
  281. Backslash: { keyCode: 220, code: 'Backslash', shiftKey: '|', key: '\\' },
  282. BracketRight: { keyCode: 221, code: 'BracketRight', shiftKey: '}', key: ']' },
  283. Quote: { keyCode: 222, code: 'Quote', shiftKey: '"', key: "'" },
  284. AltGraph: { keyCode: 225, code: 'AltGraph', key: 'AltGraph' },
  285. Props: { keyCode: 247, code: 'Props', key: 'CrSel' },
  286. Cancel: { keyCode: 3, key: 'Cancel', code: 'Abort' },
  287. Clear: { keyCode: 12, key: 'Clear', code: 'Numpad5', location: 3 },
  288. Shift: { keyCode: 16, key: 'Shift', code: 'ShiftLeft', location: 1 },
  289. Control: { keyCode: 17, key: 'Control', code: 'ControlLeft', location: 1 },
  290. Alt: { keyCode: 18, key: 'Alt', code: 'AltLeft', location: 1 },
  291. Accept: { keyCode: 30, key: 'Accept' },
  292. ModeChange: { keyCode: 31, key: 'ModeChange' },
  293. ' ': { keyCode: 32, key: ' ', code: 'Space' },
  294. Print: { keyCode: 42, key: 'Print' },
  295. Execute: { keyCode: 43, key: 'Execute', code: 'Open' },
  296. '\u0000': { keyCode: 46, key: '\u0000', code: 'NumpadDecimal', location: 3 },
  297. a: { keyCode: 65, key: 'a', code: 'KeyA' },
  298. b: { keyCode: 66, key: 'b', code: 'KeyB' },
  299. c: { keyCode: 67, key: 'c', code: 'KeyC' },
  300. d: { keyCode: 68, key: 'd', code: 'KeyD' },
  301. e: { keyCode: 69, key: 'e', code: 'KeyE' },
  302. f: { keyCode: 70, key: 'f', code: 'KeyF' },
  303. g: { keyCode: 71, key: 'g', code: 'KeyG' },
  304. h: { keyCode: 72, key: 'h', code: 'KeyH' },
  305. i: { keyCode: 73, key: 'i', code: 'KeyI' },
  306. j: { keyCode: 74, key: 'j', code: 'KeyJ' },
  307. k: { keyCode: 75, key: 'k', code: 'KeyK' },
  308. l: { keyCode: 76, key: 'l', code: 'KeyL' },
  309. m: { keyCode: 77, key: 'm', code: 'KeyM' },
  310. n: { keyCode: 78, key: 'n', code: 'KeyN' },
  311. o: { keyCode: 79, key: 'o', code: 'KeyO' },
  312. p: { keyCode: 80, key: 'p', code: 'KeyP' },
  313. q: { keyCode: 81, key: 'q', code: 'KeyQ' },
  314. r: { keyCode: 82, key: 'r', code: 'KeyR' },
  315. s: { keyCode: 83, key: 's', code: 'KeyS' },
  316. t: { keyCode: 84, key: 't', code: 'KeyT' },
  317. u: { keyCode: 85, key: 'u', code: 'KeyU' },
  318. v: { keyCode: 86, key: 'v', code: 'KeyV' },
  319. w: { keyCode: 87, key: 'w', code: 'KeyW' },
  320. x: { keyCode: 88, key: 'x', code: 'KeyX' },
  321. y: { keyCode: 89, key: 'y', code: 'KeyY' },
  322. z: { keyCode: 90, key: 'z', code: 'KeyZ' },
  323. Meta: { keyCode: 91, key: 'Meta', code: 'MetaLeft', location: 1 },
  324. '*': { keyCode: 106, key: '*', code: 'NumpadMultiply', location: 3 },
  325. '+': { keyCode: 107, key: '+', code: 'NumpadAdd', location: 3 },
  326. '-': { keyCode: 109, key: '-', code: 'NumpadSubtract', location: 3 },
  327. '/': { keyCode: 111, key: '/', code: 'NumpadDivide', location: 3 },
  328. ';': { keyCode: 186, key: ';', code: 'Semicolon' },
  329. '=': { keyCode: 187, key: '=', code: 'Equal' },
  330. ',': { keyCode: 188, key: ',', code: 'Comma' },
  331. '.': { keyCode: 190, key: '.', code: 'Period' },
  332. '`': { keyCode: 192, key: '`', code: 'Backquote' },
  333. '[': { keyCode: 219, key: '[', code: 'BracketLeft' },
  334. '\\': { keyCode: 220, key: '\\', code: 'Backslash' },
  335. ']': { keyCode: 221, key: ']', code: 'BracketRight' },
  336. "'": { keyCode: 222, key: "'", code: 'Quote' },
  337. Attn: { keyCode: 246, key: 'Attn' },
  338. CrSel: { keyCode: 247, key: 'CrSel', code: 'Props' },
  339. ExSel: { keyCode: 248, key: 'ExSel' },
  340. EraseEof: { keyCode: 249, key: 'EraseEof' },
  341. Play: { keyCode: 250, key: 'Play' },
  342. ZoomOut: { keyCode: 251, key: 'ZoomOut' },
  343. ')': { keyCode: 48, key: ')', code: 'Digit0' },
  344. '!': { keyCode: 49, key: '!', code: 'Digit1' },
  345. '@': { keyCode: 50, key: '@', code: 'Digit2' },
  346. '#': { keyCode: 51, key: '#', code: 'Digit3' },
  347. $: { keyCode: 52, key: '$', code: 'Digit4' },
  348. '%': { keyCode: 53, key: '%', code: 'Digit5' },
  349. '^': { keyCode: 54, key: '^', code: 'Digit6' },
  350. '&': { keyCode: 55, key: '&', code: 'Digit7' },
  351. '(': { keyCode: 57, key: '(', code: 'Digit9' },
  352. A: { keyCode: 65, key: 'A', code: 'KeyA' },
  353. B: { keyCode: 66, key: 'B', code: 'KeyB' },
  354. C: { keyCode: 67, key: 'C', code: 'KeyC' },
  355. D: { keyCode: 68, key: 'D', code: 'KeyD' },
  356. E: { keyCode: 69, key: 'E', code: 'KeyE' },
  357. F: { keyCode: 70, key: 'F', code: 'KeyF' },
  358. G: { keyCode: 71, key: 'G', code: 'KeyG' },
  359. H: { keyCode: 72, key: 'H', code: 'KeyH' },
  360. I: { keyCode: 73, key: 'I', code: 'KeyI' },
  361. J: { keyCode: 74, key: 'J', code: 'KeyJ' },
  362. K: { keyCode: 75, key: 'K', code: 'KeyK' },
  363. L: { keyCode: 76, key: 'L', code: 'KeyL' },
  364. M: { keyCode: 77, key: 'M', code: 'KeyM' },
  365. N: { keyCode: 78, key: 'N', code: 'KeyN' },
  366. O: { keyCode: 79, key: 'O', code: 'KeyO' },
  367. P: { keyCode: 80, key: 'P', code: 'KeyP' },
  368. Q: { keyCode: 81, key: 'Q', code: 'KeyQ' },
  369. R: { keyCode: 82, key: 'R', code: 'KeyR' },
  370. S: { keyCode: 83, key: 'S', code: 'KeyS' },
  371. T: { keyCode: 84, key: 'T', code: 'KeyT' },
  372. U: { keyCode: 85, key: 'U', code: 'KeyU' },
  373. V: { keyCode: 86, key: 'V', code: 'KeyV' },
  374. W: { keyCode: 87, key: 'W', code: 'KeyW' },
  375. X: { keyCode: 88, key: 'X', code: 'KeyX' },
  376. Y: { keyCode: 89, key: 'Y', code: 'KeyY' },
  377. Z: { keyCode: 90, key: 'Z', code: 'KeyZ' },
  378. ':': { keyCode: 186, key: ':', code: 'Semicolon' },
  379. '<': { keyCode: 188, key: '<', code: 'Comma' },
  380. _: { keyCode: 189, key: '_', code: 'Minus' },
  381. '>': { keyCode: 190, key: '>', code: 'Period' },
  382. '?': { keyCode: 191, key: '?', code: 'Slash' },
  383. '~': { keyCode: 192, key: '~', code: 'Backquote' },
  384. '{': { keyCode: 219, key: '{', code: 'BracketLeft' },
  385. '|': { keyCode: 220, key: '|', code: 'Backslash' },
  386. '}': { keyCode: 221, key: '}', code: 'BracketRight' },
  387. '"': { keyCode: 222, key: '"', code: 'Quote' }
  388. }