This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The KeyboardEvent.metaKey read-only property returning a boolean value that indicates if the Meta key was pressed (true) or not (false) when the event occurred. Some operating systems may intercept the key so it is never detected.
Note: On Macintosh keyboards, this is the ⌘ Command key.
Note: Before Firefox 118, the ⊞ Windows key was handled as an "OS" key rather than the "Meta" key. KeyboardEvent.metaKey was false when the ⊞ Windows key was pressed.
A boolean value.
<button>Click me with the meta key</button> <p id="output"></p>
document.querySelector("button").addEventListener("click", (e) => {
document.querySelector("#output").textContent =
`metaKey pressed? ${e.metaKey}`;
});
| Specification |
|---|
| UI Events> # dom-keyboardevent-metakey> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
metaKey |
1 | 12 | 1.5Since Firefox 48, the Windows key is no longer treated as ameta key. |
≤12.1 | 1.2 | 18 | 4Since Firefox for Android 48, the Windows key is no longer treated as ameta key. |
≤12.1 | 1 | 1.0 | 4.4 | 1 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/metaKey