/

HTML / CSS / JavaScript Tutorial

JavaScript Properties and Methods for KeyboardEvent objects

[this page | pdf | back links]

KeyboardEvent objects within the JavaScript DOM support the following properties:

 

Properties (when keyevent is triggered):

 

Property

Description

More

altKey

Returns true if ‘ALT’ key was pressed, otherwise returns false

Here

ctrlKey

Returns true if ‘CTRL’ key was pressed, otherwise returns false

Here

charCode

Returns Unicode character code of key triggering onkeypress event

Here

key

Returns key value of key represented by event

Here

keyCode

(Included for compatibility only, latest specification recommends using key property). Returns Unicode character code of key pressed (for onkeypress event), or Unicode key code of key that triggered onkeydown or onkeyup event

Here

location

Returns location of key on keyboard or device

Here

metaKey

Returns true if ‘META’ key was pressed, otherwise returns false

Here

shiftKey

Returns true if ‘SHIFT’ key was pressed, otherwise returns false

Here

which

(Included for compatibility only, latest specification recommends using key property). Returns Unicode character code of key pressed (for onkeypress event), or Unicode key code of key that triggered onkeydown or onkeyup event

Here

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile