| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 event._shadowKeyCode = _normalizeKeyCodes(event); | 308 event._shadowKeyCode = _normalizeKeyCodes(event); |
| 309 // Technically a "keydown" event doesn't have a charCode. This is | 309 // Technically a "keydown" event doesn't have a charCode. This is |
| 310 // calculated nonetheless to provide us with more information in giving | 310 // calculated nonetheless to provide us with more information in giving |
| 311 // as much information as possible on keypress about keycode and also | 311 // as much information as possible on keypress about keycode and also |
| 312 // charCode. | 312 // charCode. |
| 313 event._shadowCharCode = _findCharCodeKeyDown(event); | 313 event._shadowCharCode = _findCharCodeKeyDown(event); |
| 314 if (_keyDownList.length > 0 && event.keyCode != _keyDownList.last.keyCode && | 314 if (_keyDownList.length > 0 && event.keyCode != _keyDownList.last.keyCode && |
| 315 !_firesKeyPressEvent(event)) { | 315 !_firesKeyPressEvent(event)) { |
| 316 // Some browsers have quirks not firing keypress events where all other | 316 // Some browsers have quirks not firing keypress events where all other |
| 317 // browsers do. This makes them more consistent. | 317 // browsers do. This makes them more consistent. |
| 318 processKeyPress(event); | 318 processKeyPress(e); |
| 319 } | 319 } |
| 320 _keyDownList.add(event); | 320 _keyDownList.add(event); |
| 321 _dispatch(event); | 321 _dispatch(event); |
| 322 } | 322 } |
| 323 | 323 |
| 324 /** Handle keypress events. */ | 324 /** Handle keypress events. */ |
| 325 void processKeyPress(KeyboardEvent event) { | 325 void processKeyPress(KeyboardEvent event) { |
| 326 var e = new KeyEvent(event); | 326 var e = new KeyEvent(event); |
| 327 // IE reports the character code in the keyCode field for keypress events. | 327 // IE reports the character code in the keyCode field for keypress events. |
| 328 // There are two exceptions however, Enter and Escape. | 328 // There are two exceptions however, Enter and Escape. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 new _KeyboardEventHandler('keypress').forTarget(target); | 395 new _KeyboardEventHandler('keypress').forTarget(target); |
| 396 | 396 |
| 397 /** Named constructor to produce a stream for onKeyUp events. */ | 397 /** Named constructor to produce a stream for onKeyUp events. */ |
| 398 static Stream<KeyEvent> onKeyUp(EventTarget target) => | 398 static Stream<KeyEvent> onKeyUp(EventTarget target) => |
| 399 new _KeyboardEventHandler('keyup').forTarget(target); | 399 new _KeyboardEventHandler('keyup').forTarget(target); |
| 400 | 400 |
| 401 /** Named constructor to produce a stream for onKeyDown events. */ | 401 /** Named constructor to produce a stream for onKeyDown events. */ |
| 402 static Stream<KeyEvent> onKeyDown(EventTarget target) => | 402 static Stream<KeyEvent> onKeyDown(EventTarget target) => |
| 403 new _KeyboardEventHandler('keydown').forTarget(target); | 403 new _KeyboardEventHandler('keydown').forTarget(target); |
| 404 } | 404 } |
| OLD | NEW |