OLD | NEW |
1 | 1 |
2 (function() { | 2 (function() { |
3 'use strict'; | 3 'use strict'; |
4 | 4 |
5 /** | 5 /** |
6 * Chrome uses an older version of DOM Level 3 Keyboard Events | 6 * Chrome uses an older version of DOM Level 3 Keyboard Events |
7 * | 7 * |
8 * Most keys are labeled as text, but some are Unicode codepoints. | 8 * Most keys are labeled as text, but some are Unicode codepoints. |
9 * Values taken from: http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-200712
21/keyset.html#KeySet-Set | 9 * Values taken from: http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-200712
21/keyset.html#KeySet-Set |
10 */ | 10 */ |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 46: 'del', | 75 46: 'del', |
76 106: '*' | 76 106: '*' |
77 }; | 77 }; |
78 | 78 |
79 /** | 79 /** |
80 * MODIFIER_KEYS maps the short name for modifier keys used in a key | 80 * MODIFIER_KEYS maps the short name for modifier keys used in a key |
81 * combo string to the property name that references those same keys | 81 * combo string to the property name that references those same keys |
82 * in a KeyboardEvent instance. | 82 * in a KeyboardEvent instance. |
83 */ | 83 */ |
84 var MODIFIER_KEYS = { | 84 var MODIFIER_KEYS = { |
85 shift: 'shiftKey', | 85 'shift': 'shiftKey', |
86 ctrl: 'ctrlKey', | 86 'ctrl': 'ctrlKey', |
87 alt: 'altKey', | 87 'alt': 'altKey', |
88 meta: 'metaKey' | 88 'meta': 'metaKey' |
89 }; | 89 }; |
90 | 90 |
91 /** | 91 /** |
92 * KeyboardEvent.key is mostly represented by printable character made by | 92 * KeyboardEvent.key is mostly represented by printable character made by |
93 * the keyboard, with unprintable keys labeled nicely. | 93 * the keyboard, with unprintable keys labeled nicely. |
94 * | 94 * |
95 * However, on OS X, Alt+char can make a Unicode character that follows an | 95 * However, on OS X, Alt+char can make a Unicode character that follows an |
96 * Apple-specific mapping. In this case, we | 96 * Apple-specific mapping. In this case, we |
97 * fall back to .keyCode. | 97 * fall back to .keyCode. |
98 */ | 98 */ |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 _triggerKeyHandler: function(keyCombo, handlerName, keyboardEvent) { | 399 _triggerKeyHandler: function(keyCombo, handlerName, keyboardEvent) { |
400 var detail = Object.create(keyCombo); | 400 var detail = Object.create(keyCombo); |
401 detail.keyboardEvent = keyboardEvent; | 401 detail.keyboardEvent = keyboardEvent; |
402 | 402 |
403 this[handlerName].call(this, new CustomEvent(keyCombo.event, { | 403 this[handlerName].call(this, new CustomEvent(keyCombo.event, { |
404 detail: detail | 404 detail: detail |
405 })); | 405 })); |
406 } | 406 } |
407 }; | 407 }; |
408 })(); | 408 })(); |
OLD | NEW |