html
<p>Click anywhere to test the <code>shiftKey</code> property.</p>
<p id="log"></p>
JavaScript
js
let log = document.querySelector("#log");
document.addEventListener("click", logKey);
function logKey(e) {
log.textContent = `The shift key is pressed: ${e.shiftKey}`;
}
Result
Specifications
Specification |
---|
UI Events # dom-mouseevent-shiftkey |
Browser compatibility
BCD tables only load in the browser