KeyboardEvent
objects describe a user interaction with the keyboard. Each event describes a key; the event type (keydown
, keypress
, or keyup
) identifies what kind of activity was performed.
Documentation KeyboardEvent by Mozilla Contributors, licensed under CC-BY-SA 2.5.
See:
Constructor
Variables
Returns a Boolean
that is true
if the Alt ( Option or ⌥ on OS X) key was active when the key event was generated.
Returns a Number
representing the Unicode reference number of the key; this attribute is used only by the keypress
event. For keys whose char
attribute contains multiple characters, this is the Unicode value of the first character in that attribute. In Firefox 26 this returns codes for printable characters.
Warning: This attribute is deprecated; you should use KeyboardEvent.key
instead, if available.
read onlyisComposing:Bool
Returns a Boolean
that is true
if the event is fired between after compositionstart
and before compositionend
.
Returns a Number
representing a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
Warning: This attribute is deprecated; you should use KeyboardEvent.key
instead, if available.
Returns a Boolean
that is true
if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the key event was generated.
Methods
getModifierState (key:String):Bool
Returns a Boolean
indicating if the modifier key, like Alt, Shift, Ctrl, or Meta, was pressed when the event was created.
initKeyEvent (type:String, canBubble:Bool, cancelable:Bool, view:Window, ctrlKey:Bool, altKey:Bool, shiftKey:Bool, metaKey:Bool, keyCode:Int, charCode:Int):Void
Initializes a KeyboardEvent
object. This has only been implemented by Gecko (others used KeyboardEvent.initKeyboardEvent()
) and should not be used any more. The standard modern way is to use the KeyboardEvent.KeyboardEvent
constructor.