KeyboardEvent.metaKey

KeyboardEvent.metaKey 为只读属性,返回一个 布尔值,在事件发生时,用于指示 Meta 键是按下状态(true),还是释放状态(false)。

备注:在MAC键盘上,表示 Command 键(),在Windows键盘上,表示 Windows 键()。

语法

var metaKeyPressed = instanceOfKeyboardEvent.metaKey

返回值

一个布尔值

示例

 function goInput(e) {
 // 检测metaKey值
   if (e.metaKey) {
        // 继续处理事件
     superSizeOutput(e);
   } else {
     doOutput(e);
   }
 }

规范

规范版本 规范状态 备注
Document Object Model (DOM) Level 3 Events Specification
KeyboardEvent.ctrlKey
Obsolete Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
metaKeyChrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support

相关链接