KeyboardEvent.metaKey
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
KeyboardEvent.metaKey
为只读属性,返回一个 布尔值
,在事件发生时,用于指示 Meta 键是按下状态(true
),还是释放状态(false
)。
备注: 在 MAC 键盘上,表示 Command 键(⌘),在 Windows 键盘上,表示 Windows 键(⊞)。
值
一个布尔值。
示例
js
function goInput(e) {
// 检测 metaKey 值
if (e.metaKey) {
// 继续处理事件
superSizeOutput(e);
} else {
doOutput(e);
}
}
规范
Specification |
---|
UI Events # dom-keyboardevent-metakey |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
metaKey |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.