神铸利刃·装备养成活动门户

KeyboardEvent metaKey 属性

KeyboardEvent metaKey 属性

更新于 2024/2/21 23:24:00

❮ DOM 事件

❮ KeyboardEvent

实例

确定按下键盘按键时是否按下了 "META" 键:

var x = document.getElementById("demo");if (event.metaKey) { x.innerHTML = "The META key was pressed!";} else { x.innerHTML = "The META key was NOT pressed!";}

亲自试一试 »

定义和用法

metaKey 属性返回一个布尔值,该值指示在按键鼠标事件时是否按下了 "META" 键。

并非所有键盘都有 meta 键。对于 Sun 微系统键盘以及 MIT 和 LISP 机器键盘,它很常见。meta 键被标记为 "META" 或标有实心菱形 "◆" 符号。

在 Mac 键盘上,META 键由 "Command/Cmd" ("⌘") 键表示。

注释:该属性是只读的。

浏览器支持

属性

metaKey

Yes

Yes

Yes

Yes

Yes

语法

event.metaKey

技术细节

返回值:

布尔值,指示发生按键事件时是否按下了 "META" 键。

可能的值:

true - meta 键被按下

false - meta 键未被按下

DOM 版本:

DOM Level 2 Events

相关页面

HTML DOM 参考手册: KeyboardEvent altKey 属性

HTML DOM 参考手册: KeyboardEvent ctrlKey 属性

HTML DOM 参考手册: KeyboardEvent shiftKey 属性

❮ DOM 事件

❮ KeyboardEvent