HTML DOM KeyboardEvent

❮ DOM Events ❮ Event Objects


The KeyboardEvent Object

The KeyboardEvent Object handles events that occur when a user presses a key on the keyboard.

Keyboard Events

Event Occurs When
onkeydown A user presses a key
onkeypress A user presses a key
onkeyup A user releases a key

KeyboardEvent Properties

Property Returns
altKey If the ALT key was pressed
charCode Deprecated (Avoid using it)
code The code of the key that triggered the event
ctrlKey If the CTRL key was pressed
isComposing If the state of the event is composing or not
key The value of the key that triggered the event
keyCode Deprecated (Avoid using it)
location The location of a key on the keyboard or device
metaKey If the META key was pressed
repeat If a key is being hold down repeatedly, or not
shiftKey If the SHIFT key was pressed
which Deprecated (Avoid using it)

KeyboardEvent Methods

Method Description
getModifierState() Returns true if the specified key is activated

Inherited Properties and Methods

The KeyboardEvent inherits all the properties and methods from:

The UiEvent

The Event Object


❮ DOM Events ❮ Event Objects

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.