keyMap.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import { DOM_KEY_LOCATION } from '../system/keyboard.js';
  2. /**
  3. * Mapping for a default US-104-QWERTY keyboard
  4. */ const defaultKeyMap = [
  5. // alphanumeric block - writing system
  6. ...'0123456789'.split('').map((c)=>({
  7. code: `Digit${c}`,
  8. key: c
  9. })),
  10. ...')!@#$%^&*('.split('').map((c, i)=>({
  11. code: `Digit${i}`,
  12. key: c,
  13. shiftKey: true
  14. })),
  15. ...'abcdefghijklmnopqrstuvwxyz'.split('').map((c)=>({
  16. code: `Key${c.toUpperCase()}`,
  17. key: c
  18. })),
  19. ...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('').map((c)=>({
  20. code: `Key${c}`,
  21. key: c,
  22. shiftKey: true
  23. })),
  24. {
  25. code: 'BracketLeft',
  26. key: '['
  27. },
  28. {
  29. code: 'BracketLeft',
  30. key: '{',
  31. shiftKey: true
  32. },
  33. {
  34. code: 'BracketRight',
  35. key: ']'
  36. },
  37. {
  38. code: 'BracketRight',
  39. key: '}',
  40. shiftKey: true
  41. },
  42. // alphanumeric block - functional
  43. {
  44. code: 'Space',
  45. key: ' '
  46. },
  47. {
  48. code: 'AltLeft',
  49. key: 'Alt',
  50. location: DOM_KEY_LOCATION.LEFT
  51. },
  52. {
  53. code: 'AltRight',
  54. key: 'Alt',
  55. location: DOM_KEY_LOCATION.RIGHT
  56. },
  57. {
  58. code: 'ShiftLeft',
  59. key: 'Shift',
  60. location: DOM_KEY_LOCATION.LEFT
  61. },
  62. {
  63. code: 'ShiftRight',
  64. key: 'Shift',
  65. location: DOM_KEY_LOCATION.RIGHT
  66. },
  67. {
  68. code: 'ControlLeft',
  69. key: 'Control',
  70. location: DOM_KEY_LOCATION.LEFT
  71. },
  72. {
  73. code: 'ControlRight',
  74. key: 'Control',
  75. location: DOM_KEY_LOCATION.RIGHT
  76. },
  77. {
  78. code: 'MetaLeft',
  79. key: 'Meta',
  80. location: DOM_KEY_LOCATION.LEFT
  81. },
  82. {
  83. code: 'MetaRight',
  84. key: 'Meta',
  85. location: DOM_KEY_LOCATION.RIGHT
  86. },
  87. {
  88. code: 'OSLeft',
  89. key: 'OS',
  90. location: DOM_KEY_LOCATION.LEFT
  91. },
  92. {
  93. code: 'OSRight',
  94. key: 'OS',
  95. location: DOM_KEY_LOCATION.RIGHT
  96. },
  97. {
  98. code: 'ContextMenu',
  99. key: 'ContextMenu'
  100. },
  101. {
  102. code: 'Tab',
  103. key: 'Tab'
  104. },
  105. {
  106. code: 'CapsLock',
  107. key: 'CapsLock'
  108. },
  109. {
  110. code: 'Backspace',
  111. key: 'Backspace'
  112. },
  113. {
  114. code: 'Enter',
  115. key: 'Enter'
  116. },
  117. // function
  118. {
  119. code: 'Escape',
  120. key: 'Escape'
  121. },
  122. // arrows
  123. {
  124. code: 'ArrowUp',
  125. key: 'ArrowUp'
  126. },
  127. {
  128. code: 'ArrowDown',
  129. key: 'ArrowDown'
  130. },
  131. {
  132. code: 'ArrowLeft',
  133. key: 'ArrowLeft'
  134. },
  135. {
  136. code: 'ArrowRight',
  137. key: 'ArrowRight'
  138. },
  139. // control pad
  140. {
  141. code: 'Home',
  142. key: 'Home'
  143. },
  144. {
  145. code: 'End',
  146. key: 'End'
  147. },
  148. {
  149. code: 'Delete',
  150. key: 'Delete'
  151. },
  152. {
  153. code: 'PageUp',
  154. key: 'PageUp'
  155. },
  156. {
  157. code: 'PageDown',
  158. key: 'PageDown'
  159. },
  160. // Special keys that are not part of a default US-layout but included for specific behavior
  161. {
  162. code: 'Fn',
  163. key: 'Fn'
  164. },
  165. {
  166. code: 'Symbol',
  167. key: 'Symbol'
  168. },
  169. {
  170. code: 'AltRight',
  171. key: 'AltGraph'
  172. }
  173. ];
  174. export { defaultKeyMap };