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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if (Device.isIE) { | 321 if (Device.isIE) { |
322 if (e.keyCode == KeyCode.ENTER || e.keyCode == KeyCode.ESC) { | 322 if (e.keyCode == KeyCode.ENTER || e.keyCode == KeyCode.ESC) { |
323 e._shadowCharCode = 0; | 323 e._shadowCharCode = 0; |
324 } else { | 324 } else { |
325 e._shadowCharCode = e.keyCode; | 325 e._shadowCharCode = e.keyCode; |
326 } | 326 } |
327 } else if (Device.isOpera) { | 327 } else if (Device.isOpera) { |
328 // Opera reports the character code in the keyCode field. | 328 // Opera reports the character code in the keyCode field. |
329 e._shadowCharCode = KeyCode.isCharacterKey(e.keyCode) ? e.keyCode : 0; | 329 e._shadowCharCode = KeyCode.isCharacterKey(e.keyCode) ? e.keyCode : 0; |
330 } | 330 } |
331 // Now we guestimate about what the keycode is that was actually | 331 // Now we guesstimate about what the keycode is that was actually |
332 // pressed, given previous keydown information. | 332 // pressed, given previous keydown information. |
333 e._shadowKeyCode = _determineKeyCodeForKeypress(e); | 333 e._shadowKeyCode = _determineKeyCodeForKeypress(e); |
334 | 334 |
335 // Correct the key value for certain browser-specific quirks. | 335 // Correct the key value for certain browser-specific quirks. |
336 if (e._shadowKeyIdentifier != null && | 336 if (e._shadowKeyIdentifier != null && |
337 _keyIdentifier.containsKey(e._shadowKeyIdentifier)) { | 337 _keyIdentifier.containsKey(e._shadowKeyIdentifier)) { |
338 // This is needed for Safari Windows because it currently doesn't give a | 338 // This is needed for Safari Windows because it currently doesn't give a |
339 // keyCode/which for non printable keys. | 339 // keyCode/which for non printable keys. |
340 e._shadowKeyCode = _keyIdentifier[e._shadowKeyIdentifier]; | 340 e._shadowKeyCode = _keyIdentifier[e._shadowKeyIdentifier]; |
341 } | 341 } |
(...skipping 43 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 |