files/en-us/web/api/keyboardevent/metakey/index.md
{{APIRef("UI Events")}}
The KeyboardEvent.metaKey read-only property returning a
boolean value that indicates if the <kbd>Meta</kbd> 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 <kbd>⌘ Command</kbd> key.
[!NOTE] Before Firefox 118, the <kbd>⊞ Windows</kbd> key was handled as an "OS" key rather than the "Meta" key.
KeyboardEvent.metaKeywasfalsewhen the <kbd>⊞ Windows</kbd> 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}`;
});
{{ EmbedLiveSample('Examples', 400, 90) }}
{{Specifications}}
{{Compat}}