keys.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* Human readable keyCode index */
  2. var KEY = {
  3. 'BACKSPACE': 8, 'TAB': 9, 'NUM_PAD_CLEAR': 12, 'ENTER': 13, 'SHIFT': 16,
  4. 'CTRL': 17, 'ALT': 18, 'PAUSE': 19, 'CAPS_LOCK': 20, 'ESCAPE': 27,
  5. 'SPACEBAR': 32, 'PAGE_UP': 33, 'PAGE_DOWN': 34, 'END': 35, 'HOME': 36,
  6. 'ARROW_LEFT': 37, 'ARROW_UP': 38, 'ARROW_RIGHT': 39, 'ARROW_DOWN': 40,
  7. 'PRINT_SCREEN': 44, 'INSERT': 45, 'DELETE': 46, 'SEMICOLON': 59,
  8. 'WINDOWS_LEFT': 91, 'WINDOWS_RIGHT': 92, 'SELECT': 93,
  9. 'NUM_PAD_ASTERISK': 106, 'NUM_PAD_PLUS_SIGN': 107,
  10. 'NUM_PAD_HYPHEN-MINUS': 109, 'NUM_PAD_FULL_STOP': 110,
  11. 'NUM_PAD_SOLIDUS': 111, 'NUM_LOCK': 144, 'SCROLL_LOCK': 145,
  12. 'SEMICOLON': 186, 'EQUALS_SIGN': 187, 'COMMA': 188, 'HYPHEN-MINUS': 189,
  13. 'FULL_STOP': 190, 'SOLIDUS': 191, 'GRAVE_ACCENT': 192,
  14. 'LEFT_SQUARE_BRACKET': 219, 'REVERSE_SOLIDUS': 220,
  15. 'RIGHT_SQUARE_BRACKET': 221, 'APOSTROPHE': 222
  16. };
  17. (function () {
  18. /* 0 - 9 */
  19. for (var i = 48; i <= 57; i++) {
  20. KEY['' + (i - 48)] = i;
  21. }
  22. /* A - Z */
  23. for (i = 65; i <= 90; i++) {
  24. KEY['' + String.fromCharCode(i)] = i;
  25. }
  26. /* NUM_PAD_0 - NUM_PAD_9 */
  27. for (i = 96; i <= 105; i++) {
  28. KEY['NUM_PAD_' + (i - 96)] = i;
  29. }
  30. /* F1 - F12 */
  31. for (i = 112; i <= 123; i++) {
  32. KEY['F' + (i - 112 + 1)] = i;
  33. }
  34. })();