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 |