KeyboardEvent

open class KeyboardEvent(val type: EventType<KeyboardEvent>, init: KeyboardEventInit = definedExternally) : UIEvent(source)

KeyboardEvent objects describe a user interaction with the keyboard; each event describes a single interaction between the user and a key (or combination of a key with modifier keys) on the keyboard.

MDN Reference

Constructors

Link copied to clipboard
constructor(type: EventType<KeyboardEvent>, init: KeyboardEventInit = definedExternally)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The KeyboardEvent.altKey read-only property is a boolean value that indicates if the alt key (Option or on macOS) was pressed (true) or not (false) when the event occurred.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The KeyboardEvent.code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key).

Link copied to clipboard
Link copied to clipboard

The KeyboardEvent.ctrlKey read-only property returns a boolean value that indicates if the control key was pressed (true) or not (false) when the event occurred.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val detail: Int

The UIEvent.detail read-only property, when non-zero, provides the current (or next, depending on the event) click count.

Link copied to clipboard
Link copied to clipboard

The KeyboardEvent.isComposing read-only property returns a boolean value indicating if the event is fired within a composition session, i.e., after Element/compositionstart_event and before Element/compositionend_event.

Link copied to clipboard
Link copied to clipboard
val key: String

The KeyboardEvent interface's key read-only property returns the value of the key pressed by the user, taking into consideration the state of modifier keys such as Shift as well as the keyboard locale and layout.

Link copied to clipboard

The KeyboardEvent.location read-only property returns an unsigned long representing the location of the key on the keyboard or other input device.

Link copied to clipboard

The KeyboardEvent.metaKey read-only property returning a boolean value that indicates if the Meta key was pressed (true) or not (false) when the event occurred.

Link copied to clipboard
Link copied to clipboard

The repeat read-only property of the true if the given key is being held down such that it is automatically repeating.

Link copied to clipboard

The KeyboardEvent.shiftKey read-only property is a boolean value that indicates if the shift key was pressed (true) or not (false) when the event occurred.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val type: EventType<KeyboardEvent>
Link copied to clipboard
val view: Window?

The UIEvent.view read-only property returns the is the Window object the event happened in.

Functions

Link copied to clipboard
open override fun asInit(): KeyboardEventInit
Link copied to clipboard
Link copied to clipboard

The KeyboardEvent.getModifierState() method returns the current state of the specified modifier key: true if the modifier is active (that is the modifier key is pressed or locked), otherwise, false.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard