description

# KeyEvent class

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).

KeyEvent tries to provide a higher level, more polished keyboard event information on top of the "raw" KeyboardEvent.

The mechanics of using KeyEvents is a little different from the underlying KeyboardEvent. To use KeyEvents, you need to create a stream and then add KeyEvents to the stream, rather than using the EventTarget.dispatchEvent. Here's an example usage:

    // Initialize a stream for the KeyEvents:
    var stream = KeyEvent.keyPressEvent.forTarget(document.body);
    // Start listening to the stream of KeyEvents.
    stream.listen((keyEvent) =>
        window.console.log('KeyPress event detected ${keyEvent.charCode}'));
    ...
    // Add a new KeyEvent of someone pressing the 'A' key to the stream so
    // listeners can know a KeyEvent happened.
    stream.add(new KeyEvent('keypress', keyCode: 65, charCode: 97));

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!

Implemented types
  - KeyboardEvent
  - Event

## Constructors

KeyEvent(String type, {Window? view, bool canBubble = true, bool cancelable = true, int keyCode = 0, int charCode = 0, int location = 1, bool ctrlKey = false, bool altKey = false, bool shiftKey = false, bool metaKey = false, EventTarget? currentTarget})
  Programmatically create a new KeyEvent (and KeyboardEvent).
  factory
KeyEvent.wrap(KeyboardEvent parent)
  Construct a KeyEvent with `parent` as the event we're emulating.

## Properties

altKey → bool
  Calculated value of whether the alt key is pressed is for this event.
  no setter override
bubbles → bool
  no setter inherited
cancelable → bool
  no setter inherited
charCode → int
  Calculated value of what the estimated charCode is for this event.
  no setter override
code → String
  no setter override
composed → bool
  no setter inherited
ctrlKey → bool
  True if the ctrl key is pressed during this event.
  no setter override
currentTarget → EventTarget?
  The currently registered target for this event.
  no setter
defaultPrevented → bool
  no setter inherited
detail → int
  no setter override
eventPhase → int
  no setter inherited
hashCode → int
  The hash code for this object.
  no setter inherited
isComposed → bool
  no setter
isComposing → bool
  no setter override
isTrusted → bool
  no setter inherited
key → String
  no setter override
keyCode → int
  Calculated value of what the estimated keyCode is for this event.
  no setter override
location → int
  Accessor to the part of the keyboard that the key was pressed from (one of KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT, KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK).
  no setter override
matchingTarget → Element
  A pointer to the element whose CSS selector matched within which an event was fired. If this Event was not associated with any Event delegation, accessing this value will throw an UnsupportedError.
  no setter inherited
metaKey → bool
  True if the Meta (or Mac command) key is pressed during this event.
  no setter override
path → List<Node>
  This event's path, taking into account shadow DOM.
  no setter inherited
repeat → bool
  no setter override
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited
shiftKey → bool
  True if the shift key was pressed during this event.
  no setter override
sourceCapabilities → InputDeviceCapabilities?
  no setter override
target → EventTarget?
  no setter inherited
timeStamp → double
  no setter inherited
type → String
  no setter inherited
view → WindowBase?
  no setter override
which → int
  Calculated value of what the estimated keyCode is for this event.
  no setter override
wrapped → Event
  final inherited

## Methods

composedPath() → List<EventTarget>
  inherited
getModifierState(String keyArgument) → bool
  override
noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
preventDefault() → void
  inherited
stopImmediatePropagation() → void
  inherited
stopPropagation() → void
  inherited
toString() → String
  A string representation of this object.
  inherited

## Operators

operator ==(Object other) → bool
  The equality operator.
  inherited

## Static Properties

canUseDispatchEvent → bool
  no setter
keyDownEvent ↔ EventStreamProvider<KeyEvent>
  Accessor to provide a stream of KeyEvents on the desired target.
  getter/setter pair
keyPressEvent ↔ EventStreamProvider<KeyEvent>
  Accessor to provide a stream of KeyEvents on the desired target.
  getter/setter pair
keyUpEvent ↔ EventStreamProvider<KeyEvent>
  Accessor to provide a stream of KeyEvents on the desired target.
  getter/setter pair