Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:html
  3. KeyEvent class
KeyEvent
description

KeyEvent class

A custom KeyboardEvent that attempts to eliminate cross-browserinconsistencies, and also provide both keyCode and charCode informationfor all key events (when such information can be determined).

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

The mechanics of using KeyEvents is a little different from the underlyingKeyboardEvent. To use KeyEvents, you need to create a stream and then addKeyEvents to the stream, rather than using theEventTarget.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 informationon how we can make this class work with as many international keyboards aspossible. Bugs welcome!

Implemented types

Constructors

KeyEvent(Stringtype, {Window?view,boolcanBubble =true,boolcancelable =true,intkeyCode =0,intcharCode =0,intlocation =1,boolctrlKey =false,boolaltKey =false,boolshiftKey =false,boolmetaKey =false,EventTarget?currentTarget})
Programmatically create a new KeyEvent (and KeyboardEvent).
factory
KeyEvent.wrap(KeyboardEventparent)
Construct a KeyEvent withparent as the event we're emulating.

Properties

altKeybool
Calculated value of whether the alt key is pressed is for this event.
no setteroverride
bubblesbool
no setterinherited
cancelablebool
no setterinherited
charCodeint
Calculated value of what the estimated charCode is for this event.
no setteroverride
codeString
no setteroverride
composedbool
no setterinherited
ctrlKeybool
True if the ctrl key is pressed during this event.
no setteroverride
currentTargetEventTarget?
The currently registered target for this event.
no setter
defaultPreventedbool
no setterinherited
detailint
no setteroverride
eventPhaseint
no setterinherited
hashCodeint
The hash code for this object.
no setterinherited
isComposedbool
no setter
isComposingbool
no setteroverride
isTrustedbool
no setterinherited
keyString
no setteroverride
keyCodeint
Calculated value of what the estimated keyCode is for this event.
no setteroverride
locationint
Accessor to the part of the keyboard that the key was pressed from (one ofKeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK).
no setteroverride
matchingTargetElement
A pointer to the element whose CSS selector matched within which an eventwas fired. If this Event was not associated with any Event delegation,accessing this value will throw anUnsupportedError.
no setterinherited
metaKeybool
True if the Meta (or Mac command) key is pressed during this event.
no setteroverride
pathList<Node>
This event's path, taking into account shadow DOM.
no setterinherited
repeatbool
no setteroverride
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited
shiftKeybool
True if the shift key was pressed during this event.
no setteroverride
sourceCapabilitiesInputDeviceCapabilities?
no setteroverride
targetEventTarget?
no setterinherited
timeStampdouble
no setterinherited
typeString
no setterinherited
viewWindowBase?
no setteroverride
whichint
Calculated value of what the estimated keyCode is for this event.
no setteroverride
wrappedEvent
finalinherited

Methods

composedPath()List<EventTarget>
inherited
getModifierState(StringkeyArgument)bool
override
noSuchMethod(Invocationinvocation)→ 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 ==(Objectother)bool
The equality operator.
inherited

Static Properties

canUseDispatchEventbool
no setter
keyDownEventEventStreamProvider<KeyEvent>
Accessor to provide a stream of KeyEvents on the desired target.
getter/setter pair
keyPressEventEventStreamProvider<KeyEvent>
Accessor to provide a stream of KeyEvents on the desired target.
getter/setter pair
keyUpEventEventStreamProvider<KeyEvent>
Accessor to provide a stream of KeyEvents on the desired target.
getter/setter pair
  1. Dart
  2. dart:html
  3. KeyEvent class
dart:html library

[8]ページ先頭

©2009-2025 Movatter.jp