KeyboardEvent

@native @JSGlobal @JSType
class KeyboardEvent(typeArg: String, init: UndefOr[KeyboardEventInit]) extends UIEvent with ModifierKeyEvent

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.

Note: The KeyboardEvent indicates just what's happening on a key. When you need to handle text input, use HTML5 input event instead. For example, if user inputs text from hand-writing system like tablet PC, key events may not be fired.

Warning: keypress event is to be deprecated in favor of beforeinput event eventually

W3C

Companion:
object
class UIEvent
class Event
class Object
trait Any
class Object
trait Matchable
class Any

Value members

Constructors

def this(typeArg: String)

Concrete methods

def charCode: Int

Returns the Unicode value of a character key pressed during a keypress event.

Returns the Unicode value of a character key pressed during a keypress event.

Note: Required especially in Gecko based browsers

def getModifierState(keyArg: String): Boolean

Returns the current state of the specified modifier key.

Returns the current state of the specified modifier key.

def key: String

The key value of the key represented by the event. If the value has a printed representation, this attribute's value is the same as the char attribute. Otherwise, it's one of the key value strings specified in Key values. If the key can't be identified, this is the string "Unidentified". See key names for the detail.

The key value of the key represented by the event. If the value has a printed representation, this attribute's value is the same as the char attribute. Otherwise, it's one of the key value strings specified in Key values. If the key can't be identified, this is the string "Unidentified". See key names for the detail.

def keyCode: Int

A system and implementation dependent numerical code identifying the unmodified value of the pressed key. This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key; see Virtual key codes for a list of Gecko's keyCode values. If the key can't be identified, this value is 0. Read only.

A system and implementation dependent numerical code identifying the unmodified value of the pressed key. This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key; see Virtual key codes for a list of Gecko's keyCode values. If the key can't be identified, this value is 0. Read only.

def location: Int

The location of the key on the keyboard or other input device. See the constants in the KeyboardEvent object.

The location of the key on the keyboard or other input device. See the constants in the KeyboardEvent object.

def repeat: Boolean

true if the key is being held down such that it is automatically repeating

true if the key is being held down such that it is automatically repeating

Inherited methods

def `type`: String
Inherited from:
Event
def altKey: Boolean

The altKey property indicates if the alt key was pressed (true) or not (false) when the event occurred.

The altKey property indicates if the alt key was pressed (true) or not (false) when the event occurred.

Inherited from:
ModifierKeyEvent
def bubbles: Boolean

A boolean indicating whether the event bubbles up through the DOM or not.

A boolean indicating whether the event bubbles up through the DOM or not.

Inherited from:
Event
def cancelBubble: Boolean

A boolean indicating whether the bubbling of the event has been canceled or not.

A boolean indicating whether the bubbling of the event has been canceled or not.

Inherited from:
Event
def cancelable: Boolean

A boolean indicating whether the event is cancelable.

A boolean indicating whether the event is cancelable.

Inherited from:
Event
def ctrlKey: Boolean

A Boolean value indicating whether or not the control key was down when the touch event was fired. Read only.

A Boolean value indicating whether or not the control key was down when the touch event was fired. Read only.

Inherited from:
ModifierKeyEvent

Identifies the current target for the event, as the event traverses the DOM. It always refers to the element the event handler has been attached to as opposed to event.target which identifies the element on which the event occurred.

Identifies the current target for the event, as the event traverses the DOM. It always refers to the element the event handler has been attached to as opposed to event.target which identifies the element on which the event occurred.

Inherited from:
Event
def defaultPrevented: Boolean

Returns a boolean indicating whether or not event.preventDefault() was called on the event.

Returns a boolean indicating whether or not event.preventDefault() was called on the event.

Inherited from:
Event
def detail: Int

Detail about the event, depending on the type of event. Read only.

Detail about the event, depending on the type of event. Read only.

Inherited from:
UIEvent
def eventPhase: Int

Indicates which phase of the event flow is currently being evaluated.

Indicates which phase of the event flow is currently being evaluated.

Inherited from:
Event
def hasOwnProperty(v: String): Boolean
Inherited from:
Object
def isPrototypeOf(v: Object): Boolean
Inherited from:
Object
def isTrusted: Boolean

Indicates whether or not the event was initiated by the browser (after a user click for instance) or by a script (using an event creation method, like event.initEvent)

Indicates whether or not the event was initiated by the browser (after a user click for instance) or by a script (using an event creation method, like event.initEvent)

Inherited from:
Event
def metaKey: Boolean

The metaKey property indicates if the meta key was pressed (true) or not (false) when the event occurred.

The metaKey property indicates if the meta key was pressed (true) or not (false) when the event occurred.

Inherited from:
ModifierKeyEvent
def preventDefault(): Unit

Cancels the event if it is cancelable, without stopping further propagation of the event.

Cancels the event if it is cancelable, without stopping further propagation of the event.

Inherited from:
Event
def propertyIsEnumerable(v: String): Boolean
Inherited from:
Object
def shiftKey: Boolean

A Boolean value indicating whether or not the shift key was down when the touch event was fired. Read only.

A Boolean value indicating whether or not the shift key was down when the touch event was fired. Read only.

Inherited from:
ModifierKeyEvent

For this particular event, no other listener will be called. Neither those attached on the same element, nor those attached on elements which will be traversed later (in capture phase, for instance)

For this particular event, no other listener will be called. Neither those attached on the same element, nor those attached on elements which will be traversed later (in capture phase, for instance)

Inherited from:
Event
def stopPropagation(): Unit

Stops the propagation of events further along in the DOM.

Stops the propagation of events further along in the DOM.

Inherited from:
Event

This property of event objects is the object the event was dispatched on. It is different than event.currentTarget when the event handler is called in bubbling or capturing phase of the event.

This property of event objects is the object the event was dispatched on. It is different than event.currentTarget when the event handler is called in bubbling or capturing phase of the event.

Inherited from:
Event
def timeStamp: Double

Returns the time (in milliseconds since the epoch) at which the event was created.

Returns the time (in milliseconds since the epoch) at which the event was created.

Inherited from:
Event
def toLocaleString(): String
Inherited from:
Object
def valueOf(): Any
Inherited from:
Object

A view which generated the event. Read only.

A view which generated the event. Read only.

Inherited from:
UIEvent