KeyboardEvent.metaKey read-only property returning a 布尔 that indicates if the Meta key was pressed ( true ) 或不 ( false ) when the event occurred. Some operating systems may intercept the key so it is never detected.

注意: On Macintosh keyboards, this is the ⌘ Command key. On Windows keyboards, this is the Windows key ( ⊞ Windows ).

At least as of Firefox 48, the ⊞ Windows key is not considered the "Meta" key. KeyboardEvent.metaKey is false ⊞ Windows is pressed.

句法

var metaKeyPressed = instanceOfKeyboardEvent.metaKey
					

返回值

A 布尔

范例

function ismetaKey(e) {
  alert("metaKey = " + e.metaKey);
}
					
<button onclick="ismetaKey(event)">Click me with the meta key</button>
					

规范

规范 状态 注释
DOM (文档对象模型) 3 级事件规范
The definition of 'KeyboardEvent.metaKey' in that specification.
过时 初始定义

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
metaKey Chrome Yes Edge 12 Firefox Yes IE Yes Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

另请参阅

元数据

  • 最后修改: