JavaScripture
Contribute via GitHub Feedback

KeyboardEvent : UIEvent

Event containing information about key presses. See Keyboard Event Demo.

Constructors

new KeyboardEvent(type : String, [eventInit : Object]) : MouseEvent
eventInit : {
key :String
code :String
location :Number
repeat :Boolean
isComposing :Boolean
ctrlKey :Boolean
shiftKey :Boolean
altKey :Boolean
metaKey :Boolean
modifierAltGraph :Boolean
modifierCapsLock :Boolean
modifierFn :Boolean
modifierFnLock :Boolean
modifierHyper :Boolean
modifierNumLock :Boolean
modifierScrollLock :Boolean
modifierSuper :Boolean
modifierSymbol :Boolean
modifierSymbolLock :Boolean
view :Window
detail :Number
bubbles :Boolean
cancelable :Boolean
composed :Boolean
}

Creates a new KeyboardEvent of the specified type and initial properties.

Instance Properties

altKey : Boolean  

Returns true if the keyboard's alt (Option on Mac) key is pressed. See also getModifierState().

Example:

Run

Results:

 

charCode : Number  

The effective character. Only valid for keypress events. Use String.fromCharCode() to get a string version of the pressed character.

Example:

Run

Results:

 

code : String  

Example:

Run

Results:

 

ctrlKey : Boolean  

Returns true if the keyboard's control key is pressed. See also getModifierState().

Example:

Run

Results:

 

key : String  

Example:

Run

Results:

 

keyCode : Number  

Example:

Run

Results:

 

location : Number  

One of DOM_KEY_LOCATION_STANDARD, DOM_KEY_LOCATION_LEFT, DOM_KEY_LOCATION_RIGHT, DOM_KEY_LOCATION_NUMPAD.

Example:

Run

Results:

 

metaKey : Boolean  

Returns true if the keyboard's meta (Command on Mac, the Windows logo key in some PC browsers) key is pressed. See also getModifierState().

Example:

Run

Results:

 

repeat : Boolean  

Returns true if the key event was generate by the user holding the key down.

Example:

Run

Results:

 

shiftKey : Boolean  

Returns true if the keyboard's shift key is pressed. See also getModifierState().

Example:

Run

Results:

 

which : Number  

Example:

Run

Results:

 

Instance Methods

getModifierState(modifierKey : String) : Boolean

Returns true if the the modifierKey is pressed or active. modifierKey must be one of 'Alt', 'AltGraph', 'CapsLock', 'Control', 'Fn', 'Meta', 'NumLock', 'ScrollLock', 'Shift', or 'SymbolLock'.

KeyboardEvent Properties

DOM_KEY_LOCATION_LEFT : Number    

DOM_KEY_LOCATION_NUMPAD : Number    

DOM_KEY_LOCATION_RIGHT : Number    

DOM_KEY_LOCATION_STANDARD : Number