@DOMObjectAttribute @DOMNameAttribute(name="KeyboardEvent") public class KeyboardEvent extends UIEvent
The KeyboardEvent interface provides specific contextual information associated with keyboard devices. Each keyboard event references a key using a value. Keyboard events are commonly directed at the element that has the focus.
Modifier and Type | Class and Description |
---|---|
class |
KeyboardEvent.KeyboardEventInit
Represents a dictionary that is having optional arguments for setting the details information about the event.
|
UIEvent.EventModifierInit, UIEvent.UIEventInit
Event.EventInit
Modifier and Type | Field and Description |
---|---|
static long |
DOM_KEY_LOCATION_LEFT
The key activated originated from the left key location (when there is more than one possible location for this key).
|
static long |
DOM_KEY_LOCATION_NUMPAD
The key activation originated on the numeric keypad or with a virtual key corresponding to the numeric keypad (when there is more than one possible location for this key).
|
static long |
DOM_KEY_LOCATION_RIGHT
The key activation originated from the right key location (when there is more than one possible location for this key).
|
static long |
DOM_KEY_LOCATION_STANDARD
The key activation MUST NOT be distinguished as the left or right version of the key, and (other than the NumLock key) did not originate from the numeric keypad (or did not originate with a virtual key corresponding to the numeric keypad).
|
AT_TARGET_PHASE, BUBBLING_PHASE, CAPTURING_PHASE, NONE_PHASE
PropertyChanged
Constructor and Description |
---|
KeyboardEvent(String type)
Initializes a new instance of the
KeyboardEvent class. |
KeyboardEvent(String type,
KeyboardEvent.KeyboardEventInit eventInitDict)
Initializes a new instance of the
KeyboardEvent class. |
Modifier and Type | Method and Description |
---|---|
static Event |
createEvent(String type,
KeyboardEvent.KeyboardEventInit eventInit) |
static Event |
createKeyDownEvent(KeyboardEvent.KeyboardEventInit eventInit) |
static Event |
createKeyPressEvent(KeyboardEvent.KeyboardEventInit eventInit) |
static Event |
createKeyUpEvent(KeyboardEvent.KeyboardEventInit eventInit) |
boolean |
getAltKey()
true if the Alt (alternative) (or "Option") key modifier was active.
|
String |
getCode()
The code holds a string that identifies the physical key being pressed.
|
boolean |
getCtrlKey()
true if the Control (control) key modifier was active.
|
String |
getKey()
The key holds the key value of the key pressed.
|
long |
getLocation()
The location attribute contains an indication of the logical location of the key on the device.
|
boolean |
getMetaKey()
true if the meta (Meta) key modifier was active.
|
boolean |
getRepeat()
true if the key has been pressed in a sustained manner.
|
boolean |
getShiftKey()
true if the shift (Shift) key modifier was active.
|
boolean |
isComposing()
true if the key event occurs as part of a composition session, i.e., after a compositionstart event and before the corresponding compositionend event.
|
createAbortEvent, createEvent, createLoadEvent, createSelectEvent, createUnLoadEvent, getDetail, getView
createDOMContentLoadedEvent, createError, createEvent, createEvent, createEventByType, dispatch, getBubbles, getCancelable, getCurrentTarget, getDefaultPrevented, getEventPhase, getTarget, getTimeStamp, getType, initEvent, isTrusted, preventDefault, setCurrentTarget, setEventPhase, setTarget, stopImmediatePropagation, stopPropagation
fireNotifyPropertyChanged, getCurrentValues, getRuntimesBinding, setCurrentValues, setField, setRuntimesBinding
public static final long DOM_KEY_LOCATION_STANDARD
The key activation MUST NOT be distinguished as the left or right version of the key, and (other than the NumLock key) did not originate from the numeric keypad (or did not originate with a virtual key corresponding to the numeric keypad).
public static final long DOM_KEY_LOCATION_LEFT
The key activated originated from the left key location (when there is more than one possible location for this key).
public static final long DOM_KEY_LOCATION_RIGHT
The key activation originated from the right key location (when there is more than one possible location for this key).
public static final long DOM_KEY_LOCATION_NUMPAD
The key activation originated on the numeric keypad or with a virtual key corresponding to the numeric keypad (when there is more than one possible location for this key). Note that the NumLock key should always be encoded with a location of DOM_KEY_LOCATION_STANDARD.
public KeyboardEvent(String type)
Initializes a new instance of the KeyboardEvent
class.
type
- The event type.public KeyboardEvent(String type, KeyboardEvent.KeyboardEventInit eventInitDict)
Initializes a new instance of the KeyboardEvent
class.
type
- The event type.eventInitDict
- The event initialize dictionary.public static Event createKeyDownEvent(KeyboardEvent.KeyboardEventInit eventInit)
public static Event createKeyPressEvent(KeyboardEvent.KeyboardEventInit eventInit)
public static Event createKeyUpEvent(KeyboardEvent.KeyboardEventInit eventInit)
public static Event createEvent(String type, KeyboardEvent.KeyboardEventInit eventInit)
@DOMNameAttribute(name="key") public String getKey()
The key holds the key value of the key pressed. If the value is has a printed representation, it MUST be a non-empty Unicode character string, conforming to the algorithm for determining the key value defined in this specification. If the value is a control key which has no printed representation, it MUST be one of the key values defined in the key values set, as determined by the algorithm for determining the key value. Implementations that are unable to identify a key MUST use the key value Unidentified.
Value: The key value.@DOMNameAttribute(name="code") public String getCode()
The code holds a string that identifies the physical key being pressed. The value is not affected by the current keyboard layout or modifier state, so a particular key will always return the same value.
Value: The key code.@DOMNameAttribute(name="location") public long getLocation()
The location attribute contains an indication of the logical location of the key on the device.
Value: The location.@DOMNameAttribute(name="ctrlKey") public boolean getCtrlKey()
true if the Control (control) key modifier was active. The un-initialized value of this attribute MUST be false.
Value:true
if Control; otherwise, false
.@DOMNameAttribute(name="shiftKey") public boolean getShiftKey()
true if the shift (Shift) key modifier was active.
Value:true
if Shift; otherwise, false
.@DOMNameAttribute(name="altKey") public boolean getAltKey()
true if the Alt (alternative) (or "Option") key modifier was active. The un-initialized value of this attribute MUST be false.
Value:true
if Alt; otherwise, false
.@DOMNameAttribute(name="metaKey") public boolean getMetaKey()
true if the meta (Meta) key modifier was active.
Value:true
if Meta; otherwise, false
.@DOMNameAttribute(name="repeat") public boolean getRepeat()
true if the key has been pressed in a sustained manner. Holding down a key MUST result in the repeating the events keydown, beforeinput, input in this order, at a rate determined by the system configuration. For mobile devices which have long-key-press behavior, the first key event with a repeat attribute value of true MUST serve as an indication of a long-key-press. The length of time that the key MUST be pressed in order to begin repeating is configuration-dependent.
Value:true
if repeat; otherwise, false
.@DOMNameAttribute(name="isComposing") public boolean isComposing()
true if the key event occurs as part of a composition session, i.e., after a compositionstart event and before the corresponding compositionend event. The un-initialized value of this attribute MUST be false.
Value:true
if this instance is composing; otherwise, false
.