A
布尔
value indicating whether or not the
alt
(Alternate) key is enabled when the touch event is created. If the
alt
key is enabled, the attribute's value is
true
. Otherwise, it is
false
.
此特性是 只读 .
var altEnabled = touchEvent.altKey;
altEnabled
true
若
alt
key is enabled for this event; and
false
若
alt
is not enabled.
This example illustrates how to access the
TouchEvent
key modifier properties:
TouchEvent.altKey
,
TouchEvent.ctrlKey
,
TouchEvent.metaKey
and
TouchEvent.shiftKey
.
In following code snippet, the
touchstart
event handler logs the state of the event's modifier keys.
someElement.addEventListener('touchstart', function(e) {
// Log the state of this event's modifier keys
console.log("altKey = " + e.altKey);
console.log("ctrlKey = " + e.ctrlKey);
console.log("metaKey = " + e.metaKey);
console.log("shiftKey = " + e.shiftKey);
}, false);
| 规范 | 状态 | 注释 |
|---|---|---|
| Touch Events – Level 2 | 草案 | 非稳定版本。 |
| 触摸事件 | 推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
altKey
|
Chrome 22 | Edge ≤18 |
Firefox
52
|
IE No | Opera Yes | Safari No | WebView Android Yes | Chrome Android Yes | Firefox Android 6 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
不支持
TouchEvent