KeyboardEvent extension type
KeyboardEvent
objects describe a user interaction with the keyboard;
each event describes a single interaction between the user and a key (or
combination of a key with modifier keys) on the keyboard. The event type
(Element/keydown_event
, Element/keypress_event
, or
Element/keyup_event
) identifies what kind of keyboard activity occurred.
Note:
KeyboardEvent
events just indicate what interaction the user had with a key on the keyboard at a low level, providing no contextual meaning to that interaction. When you need to handle text input, use theElement/input_event
event instead. Keyboard events may not be fired if the user is using an alternate means of entering text, such as a handwriting system on a tablet or graphics tablet.
Constructors
- KeyboardEvent(String type, [KeyboardEventInit eventInitDict])
-
factory
Properties
- altKey → bool
-
no setter
- bubbles → bool
-
no setterinherited
- cancelable → bool
-
no setterinherited
- cancelBubble ↔ bool
-
getter/setter pairinherited
- charCode → int
-
no setter
- code → String
-
no setter
- composed → bool
-
no setterinherited
- ctrlKey → bool
-
no setter
- currentTarget → EventTarget?
-
no setterinherited
- defaultPrevented → bool
-
no setterinherited
- detail → int
-
no setterinherited
- eventPhase → int
-
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isComposing → bool
-
no setter
- isTrusted → bool
-
no setterinherited
- key → String
-
no setter
- keyCode → int
-
no setter
- location → int
-
no setter
- metaKey → bool
-
no setter
- repeat → bool
-
no setter
- returnValue ↔ bool
-
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shiftKey → bool
-
no setter
- srcElement → EventTarget?
-
no setterinherited
- target → EventTarget?
-
no setterinherited
- timeStamp → DOMHighResTimeStamp
-
no setterinherited
- type → String
-
no setterinherited
- view → Window?
-
no setterinherited
- which → int
-
no setterinherited
Methods
-
composedPath(
) → JSArray< EventTarget> -
The
composedPath()
method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked. This does not include nodes in shadow trees if the shadow root was created with its ShadowRoot.mode closed.inherited -
getModifierState(
String keyArg) → bool -
The
KeyboardEvent.getModifierState()
method returns the current state of the specified modifier key:true
if the modifier is active (that is the modifier key is pressed or locked), otherwise,false
. -
initEvent(
String type, [bool bubbles, bool cancelable]) → void -
The
Event.initEvent()
method is used to initialize the value of anevent
created using Document.createEvent.inherited -
initKeyboardEvent(
String typeArg, [bool bubblesArg, bool cancelableArg, Window? viewArg, String keyArg, int locationArg, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey]) → void -
The
KeyboardEvent.initKeyboardEvent()
method initializes the attributes of a keyboard event object. This method was introduced in draft of DOM Level 3 Events, but deprecated in newer draft. Gecko won't support this feature since implementing this method as experimental broke existing web apps (see Firefox bug 999645). Web applications should use constructor instead of this if it's available. -
initUIEvent(
String typeArg, [bool bubblesArg, bool cancelableArg, Window? viewArg, int detailArg]) → void -
The
UIEvent.initUIEvent()
method initializes a UI event once it's been created.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
preventDefault(
) → void -
The
preventDefault()
method of the Event interface tells the that if the event does not get explicitly handled, its default action should not be taken as it normally would be.inherited -
stopImmediatePropagation(
) → void -
The
stopImmediatePropagation()
method of the Event interface prevents other listeners of the same event from being called.inherited -
stopPropagation(
) → void -
The
stopPropagation()
method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on links are still processed. If you want to stop those behaviors, see the Event.preventDefault method. It also does not prevent propagation to other event-handlers of the current element. If you want to stop those, see Event.stopImmediatePropagation.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- DOM_KEY_LOCATION_LEFT → int
-
no setter
- DOM_KEY_LOCATION_NUMPAD → int
-
no setter
- DOM_KEY_LOCATION_RIGHT → int
-
no setter
- DOM_KEY_LOCATION_STANDARD → int
-
no setter