keypress keydown code example
Example 1: javascript keydown
document.addEventListener("keydown", function(event) {
if (event.keyCode == 32) {
console.log("Space was pressed!");
}
});
Example 2: what is keyup and keydown
Keydown and keyup. The keydown events happens when a key is pressed down, and then keyup – when it's released