How to capture key press, e.g., Ctrl+Z, without placing an input element on the page in JavaScript? Seems that in IE, keypress and keyup events can only be bound to input el
event.key
document.addEventListener("keypress", function onPress(event) { if (event.key === "z" && event.ctrlKey) { // Do something awesome } });
NOTE: The old properties (.keyCode and .which) are Deprecated.
.keyCode
.which
Mozilla Docs
Supported Browsers