Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: sdk/lib/html/src/dartium_KeyEvent.dart

Issue 11416249: Make KeyboardEvent cross-browser consistent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: documentation fix Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /**
2 * A custom KeyboardEvent that attempts to eliminate cross-browser
3 * inconsistencies, and also provide both keyCode and charCode information
4 * for all key events (when such information can be determined).
5 *
6 * This class is very much a work in progress, and we'd love to get information
7 * on how we can make this class work with as many international keyboards as
8 * possible. Bugs welcome!
9 */
10 class KeyEvent implements KeyboardEvent {
11 /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
12 KeyboardEvent _parent;
13
14 /** The "fixed" value of whether the alt key is being pressed. */
15 bool _shadowAltKey;
16
17 /** Caculated value of what the estimated charCode is for this event. */
18 int _shadowCharCode;
19
20 /** Caculated value of what the estimated keyCode is for this event. */
21 int _shadowKeyCode;
22
23 /** Caculated value of what the estimated keyCode is for this event. */
24 int get keyCode => _shadowKeyCode;
25
26 /** Caculated value of what the estimated charCode is for this event. */
27 int get charCode => this.type == 'keypress' ? _shadowCharCode : 0;
28
29 /** Caculated value of whether the alt key is pressed is for this event. */
30 bool get altKey => _shadowAltKey;
31
32 /** Caculated value of what the estimated keyCode is for this event. */
33 int get which => keyCode;
34
35 /** Accessor to the underlying keyCode value is the parent event. */
36 int get _realKeyCode => _parent.keyCode;
37
38 /** Accessor to the underlying charCode value is the parent event. */
39 int get _realCharCode => _parent.charCode;
40
41 /** Accessor to the underlying altKey value is the parent event. */
42 bool get _realAltKey => _parent.altKey;
43
44 /** Construct a KeyEvent with [parent] as event we're emulating. */
45 KeyEvent(KeyboardEvent parent) {
46 _parent = parent;
47 _shadowAltKey = _realAltKey;
48 _shadowCharCode = _realCharCode;
49 _shadowKeyCode = _realKeyCode;
50 }
51
52 /**
53 * Catch-all to behave for all other methods not defined here just like the
54 * _parent.
55 */
56 void noSuchMethod(InvocationMirror invocation) {
57 invocation.invokeOn(_parent);
58 }
59 String get _shadowKeyIdentifier => _parent.$dom_keyIdentifier;
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698