OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of html; | 5 part of html; |
6 | 6 |
7 /** | 7 /** |
8 * Internal class that does the actual calculations to determine keyCode and | 8 * Internal class that does the actual calculations to determine keyCode and |
9 * charCode for keydown, keypress, and keyup events for all browsers. | 9 * charCode for keydown, keypress, and keyup events for all browsers. |
10 */ | 10 */ |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 return KeyCode.UNKNOWN; | 127 return KeyCode.UNKNOWN; |
128 } | 128 } |
129 | 129 |
130 /** | 130 /** |
131 * Given the character code returned from a keyDown [event], try to ascertain | 131 * Given the character code returned from a keyDown [event], try to ascertain |
132 * and return the corresponding charCode for the character that was pressed. | 132 * and return the corresponding charCode for the character that was pressed. |
133 * This information is not shown to the user, but used to help polyfill | 133 * This information is not shown to the user, but used to help polyfill |
134 * keypress events. | 134 * keypress events. |
135 */ | 135 */ |
136 int _findCharCodeKeyDown(KeyboardEvent event) { | 136 int _findCharCodeKeyDown(KeyboardEvent event) { |
137 if (event.keyLocation == 3) { | 137 if (event.location == 3) { |
138 // Numpad keys. | 138 // Numpad keys. |
139 switch (event.keyCode) { | 139 switch (event.keyCode) { |
140 case KeyCode.NUM_ZERO: | 140 case KeyCode.NUM_ZERO: |
141 // Even though this function returns _charCodes_, for some cases the | 141 // Even though this function returns _charCodes_, for some cases the |
142 // KeyCode == the charCode we want, in which case we use the keycode | 142 // KeyCode == the charCode we want, in which case we use the keycode |
143 // constant for readability. | 143 // constant for readability. |
144 return KeyCode.ZERO; | 144 return KeyCode.ZERO; |
145 case KeyCode.NUM_ONE: | 145 case KeyCode.NUM_ONE: |
146 return KeyCode.ONE; | 146 return KeyCode.ONE; |
147 case KeyCode.NUM_TWO: | 147 case KeyCode.NUM_TWO: |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 new _KeyboardEventHandler('keypress').forTarget(target); | 385 new _KeyboardEventHandler('keypress').forTarget(target); |
386 | 386 |
387 /** Named constructor to produce a stream for onKeyUp events. */ | 387 /** Named constructor to produce a stream for onKeyUp events. */ |
388 static CustomStream<KeyEvent> onKeyUp(EventTarget target) => | 388 static CustomStream<KeyEvent> onKeyUp(EventTarget target) => |
389 new _KeyboardEventHandler('keyup').forTarget(target); | 389 new _KeyboardEventHandler('keyup').forTarget(target); |
390 | 390 |
391 /** Named constructor to produce a stream for onKeyDown events. */ | 391 /** Named constructor to produce a stream for onKeyDown events. */ |
392 static CustomStream<KeyEvent> onKeyDown(EventTarget target) => | 392 static CustomStream<KeyEvent> onKeyDown(EventTarget target) => |
393 new _KeyboardEventHandler('keydown').forTarget(target); | 393 new _KeyboardEventHandler('keydown').forTarget(target); |
394 } | 394 } |
OLD | NEW |