MDN self-hosted library · e01.org

MouseEvent: shiftKey property

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

html
<p>Click anywhere to test the <code>shiftKey</code> property.</p>
<p id="log"></p>
js
let log = document.querySelector("#log");
document.addEventListener("click", logKey);

function logKey(e) {
  log.textContent = `The shift key is pressed: ${e.shiftKey}`;
}