| Index: sdk/lib/html/src/dartium_KeyEvent.dart
|
| diff --git a/sdk/lib/html/src/dartium_KeyEvent.dart b/sdk/lib/html/src/dartium_KeyEvent.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..86a1bae17c3520bcf21e5f9c10cf82920f82b141
|
| --- /dev/null
|
| +++ b/sdk/lib/html/src/dartium_KeyEvent.dart
|
| @@ -0,0 +1,60 @@
|
| +/**
|
| + * A custom KeyboardEvent that attempts to eliminate cross-browser
|
| + * inconsistencies, and also provide both keyCode and charCode information
|
| + * for all key events (when such information can be determined).
|
| + *
|
| + * This class is very much a work in progress, and we'd love to get information
|
| + * on how we can make this class work with as many international keyboards as
|
| + * possible. Bugs welcome!
|
| + */
|
| +class KeyEvent implements KeyboardEvent {
|
| + /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
|
| + KeyboardEvent _parent;
|
| +
|
| + /** The "fixed" value of whether the alt key is being pressed. */
|
| + bool _shadowAltKey;
|
| +
|
| + /** Caculated value of what the estimated charCode is for this event. */
|
| + int _shadowCharCode;
|
| +
|
| + /** Caculated value of what the estimated keyCode is for this event. */
|
| + int _shadowKeyCode;
|
| +
|
| + /** Caculated value of what the estimated keyCode is for this event. */
|
| + int get keyCode => _shadowKeyCode;
|
| +
|
| + /** Caculated value of what the estimated charCode is for this event. */
|
| + int get charCode => this.type == 'keypress' ? _shadowCharCode : 0;
|
| +
|
| + /** Caculated value of whether the alt key is pressed is for this event. */
|
| + bool get altKey => _shadowAltKey;
|
| +
|
| + /** Caculated value of what the estimated keyCode is for this event. */
|
| + int get which => keyCode;
|
| +
|
| + /** Accessor to the underlying keyCode value is the parent event. */
|
| + int get _realKeyCode => _parent.keyCode;
|
| +
|
| + /** Accessor to the underlying charCode value is the parent event. */
|
| + int get _realCharCode => _parent.charCode;
|
| +
|
| + /** Accessor to the underlying altKey value is the parent event. */
|
| + bool get _realAltKey => _parent.altKey;
|
| +
|
| + /** Construct a KeyEvent with [parent] as event we're emulating. */
|
| + KeyEvent(KeyboardEvent parent) {
|
| + _parent = parent;
|
| + _shadowAltKey = _realAltKey;
|
| + _shadowCharCode = _realCharCode;
|
| + _shadowKeyCode = _realKeyCode;
|
| + }
|
| +
|
| + /**
|
| + * Catch-all to behave for all other methods not defined here just like the
|
| + * _parent.
|
| + */
|
| + void noSuchMethod(InvocationMirror invocation) {
|
| + invocation.invokeOn(_parent);
|
| + }
|
| + String get _shadowKeyIdentifier => _parent.$dom_keyIdentifier;
|
| +}
|
|
|