MDN self-hosted library · e01.org

KeyboardEvent: metaKey property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<button>Click me with the meta key</button>

<p id="output"></p>
js
document.querySelector("button").addEventListener("click", (e) => {
  document.querySelector("#output").textContent =
    `metaKey pressed? ${e.metaKey}`;
});