keynames.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Copyright 2006 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Constant declarations for common key codes.
  16. *
  17. * @author eae@google.com (Emil A Eklund)
  18. */
  19. goog.provide('goog.events.KeyNames');
  20. /**
  21. * Key names for common characters. These should be used with keyup/keydown
  22. * events, since the .keyCode property on those is meant to indicate the
  23. * *physical key* the user held down on the keyboard. Hence the mapping uses
  24. * only the unshifted version of each key (e.g. no '#', since that's shift+3).
  25. * Keypress events on the other hand generate (mostly) ASCII codes since they
  26. * correspond to *characters* the user typed.
  27. *
  28. * For further reference: http://unixpapa.com/js/key.html
  29. *
  30. * This list is not localized and therefore some of the key codes are not
  31. * correct for non-US keyboard layouts.
  32. *
  33. * @see goog.events.KeyCodes
  34. * @enum {string}
  35. */
  36. goog.events.KeyNames = {
  37. 8: 'backspace',
  38. 9: 'tab',
  39. 13: 'enter',
  40. 16: 'shift',
  41. 17: 'ctrl',
  42. 18: 'alt',
  43. 19: 'pause',
  44. 20: 'caps-lock',
  45. 27: 'esc',
  46. 32: 'space',
  47. 33: 'pg-up',
  48. 34: 'pg-down',
  49. 35: 'end',
  50. 36: 'home',
  51. 37: 'left',
  52. 38: 'up',
  53. 39: 'right',
  54. 40: 'down',
  55. 45: 'insert',
  56. 46: 'delete',
  57. 48: '0',
  58. 49: '1',
  59. 50: '2',
  60. 51: '3',
  61. 52: '4',
  62. 53: '5',
  63. 54: '6',
  64. 55: '7',
  65. 56: '8',
  66. 57: '9',
  67. 59: 'semicolon',
  68. 61: 'equals',
  69. 65: 'a',
  70. 66: 'b',
  71. 67: 'c',
  72. 68: 'd',
  73. 69: 'e',
  74. 70: 'f',
  75. 71: 'g',
  76. 72: 'h',
  77. 73: 'i',
  78. 74: 'j',
  79. 75: 'k',
  80. 76: 'l',
  81. 77: 'm',
  82. 78: 'n',
  83. 79: 'o',
  84. 80: 'p',
  85. 81: 'q',
  86. 82: 'r',
  87. 83: 's',
  88. 84: 't',
  89. 85: 'u',
  90. 86: 'v',
  91. 87: 'w',
  92. 88: 'x',
  93. 89: 'y',
  94. 90: 'z',
  95. 93: 'context',
  96. 96: 'num-0',
  97. 97: 'num-1',
  98. 98: 'num-2',
  99. 99: 'num-3',
  100. 100: 'num-4',
  101. 101: 'num-5',
  102. 102: 'num-6',
  103. 103: 'num-7',
  104. 104: 'num-8',
  105. 105: 'num-9',
  106. 106: 'num-multiply',
  107. 107: 'num-plus',
  108. 109: 'num-minus',
  109. 110: 'num-period',
  110. 111: 'num-division',
  111. 112: 'f1',
  112. 113: 'f2',
  113. 114: 'f3',
  114. 115: 'f4',
  115. 116: 'f5',
  116. 117: 'f6',
  117. 118: 'f7',
  118. 119: 'f8',
  119. 120: 'f9',
  120. 121: 'f10',
  121. 122: 'f11',
  122. 123: 'f12',
  123. 186: 'semicolon',
  124. 187: 'equals',
  125. 189: 'dash',
  126. 188: ',',
  127. 190: '.',
  128. 191: '/',
  129. 192: '`',
  130. 219: 'open-square-bracket',
  131. 220: '\\',
  132. 221: 'close-square-bracket',
  133. 222: 'single-quote',
  134. 224: 'win'
  135. };