KeyboardEvent location Property
Description
The location
property returns the location of a pressed key.
The location
property is read-only.
The location
property returns a number (0-4):
0 (DOM_KEY_LOCATION_STANDARD):
The value 0 represents almost every key on the keyboard
1 (DOM_KEY_LOCATION_LEFT):
The left key was pressed (like left CTRL and ALT)
2 (DOM_KEY_LOCATION_RIGHT):
The right key was pressed (like right CTRL and ALT)
3 (DOM_KEY_LOCATION_NUMPAD):
The key was pressed on the numeric keypad.
Note
The location
property can only be used on the
onkeydown and onkeyup event.
The location
property can not be used on the onkeypress event.
See Also:
Syntax
event.location
Technical Details
Return Value: |
A Number. The location of a the key on the keyboard or device: 0. DOM_KEY_LOCATION_STANDARD 1. DOM_KEY_LOCATION_LEFT 2. DOM_KEY_LOCATION_RIGHT 3. DOM_KEY_LOCATION_NUMPAD |
---|---|
DOM Version: | DOM Level 3 Keyboard Events. |
Browser Support
event.location
is a DOM Level 3 (2004) feature.
It is fully supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |