Course recommendation:
KeyboardEvent location property
Definition and usage
This number is represented by 4 constants:
The location property returns a number indicating the position of the key on the keyboard or device.0. DOM_KEY_LOCATION_STANDARD:
The key is not pressed on the right or left side of the keyboard, nor on the numeric keypad (this value represents almost every key on the keyboard, such as "A", "U", "SPACE", or "5")1. DOM_KEY_LOCATION_LEFT:
The left key is pressed (for example, the left "CTRL" key or left "ALT" key on a standard 101-key US keyboard)2. DOM_KEY_LOCATION_RIGHT:
The right key is pressed (for example, the right "CTRL" key or right "ALT" key on a standard 101-key US keyboard)3. DOM_KEY_LOCATION_NUMPAD:
Note:When the key is pressed on the numeric keypad (for example, the "2" key on the right side of a standard keyboard) The location property can only be used onkeydown and event, cannot be used onkeypress.
Note:This property is read-only.
Syntax
event.location
Technical details
Return value: |
Numeric value, indicating the position of the key on the keyboard or device. This number is represented by 4 constants:
|
---|---|
DOM version: | DOM Level 3 Events |
Webbläsarstöd
Numreringen i tabellen anger den första webbläsarens version som fullständigt stöder egenskapen.
Egenskaper | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
location | Stödjer | 9.0 | 15.0 | Stödjer inte | Stödjer |