Key code
Shows the value of a key or keys pressed by the user and the implementation depended key code.
Press any key
KeyboardEvent.key = ""
KeyboardEvent.keyCode = ""
The KeyboardEvent.key read-only property returns the value of a key or keys pressed by the user. Its value is determined as follows:
- If the pressed key has a printed representation, the returned value is a non-empty Unicode character string containing the printable representation of the key.
- If the pressed key is a control or special character, the returned value is one of the pre-defined key values.
- If the KeyboardEvent represents the press of a dead key, the key value must be "Dead".
- If more than one key is pressed and the combination includes a modifier that makes the resulting keystroke non printing, the returned value is the printable character. For example, if the combination were Control + a, the letter "a" is returned.
- If the key cannot be identified, the returned value is "Unidentified".
See also
Char codeAdditional information
The KeyboardEvent.key read-only property returns the value of a key or keys pressed by the user. Read more
Source code
Keywords
key
value
pressed
keyCode