<p>Click anywhere to test the <code>altKey</code> property.</p>
<p id="log"></p>MouseEvent: altKey property / notebook
MouseEvent: altKey property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
let log = document.querySelector("#log");
document.addEventListener("click", logKey);
function logKey(e) {
log.textContent = `The alt key is pressed: ${e.altKey}`;
}