KeyboardEvent location 属性
描述
location
属性返回按下键的位置。
location
属性是只读的。
location
属性返回一个数字(0-4)
0 (DOM_KEY_LOCATION_STANDARD)
值 0 代表键盘上的几乎所有键
1 (DOM_KEY_LOCATION_LEFT)
按下的是左键(例如左 CTRL 和 ALT)
2 (DOM_KEY_LOCATION_RIGHT)
按下的是右键(例如右 CTRL 和 ALT)
3 (DOM_KEY_LOCATION_NUMPAD)
按键是在数字小键盘上按下的。
语法
event.location
技术详情
返回值 | 一个数字。 键盘或设备上按键的位置 0. DOM_KEY_LOCATION_STANDARD 1. DOM_KEY_LOCATION_LEFT 2. DOM_KEY_LOCATION_RIGHT 3. DOM_KEY_LOCATION_NUMPAD |
---|---|
DOM 版本 | DOM Level 3 键盘事件。 |
浏览器支持
event.location
是 DOM Level 3 (2004) 功能。
所有现代浏览器都完全支持它
Chrome | Edge | Firefox | Safari | Opera | IE |
是 | 是 | 是 | 是 | 是 | 11 |