location property
Gets the location of a key on the keyboard or device.
![]() ![]() |
Syntax
| JavaScript | |
|---|
Property values
Type: Integer
-
The key is not on the right or left, and it did not originate from the numeric keypad (for example, the Q key).
-
A left key was activated (for example, the left Shift key).
-
A right key was activated (for example, the right Shift key).
-
The key originated on the numeric keypad (for example, the 1 key on the numeric keypad).
-
The key originated on the physical or virtual keyboard of a mobile device.
-
The key originated on a game controller or joystick.
Standards information
- Document Object Model (DOM) Level 3 Events Specification, Section 5.2.6
Remarks
The location property is not set during onkeypress events. It is available only during onkeydown and onkeyup events.
See also
- KeyboardEvent
- Reference
- onkeydown
- onkeyup
Show:

