The event object for a keydown event has a Boolean property called repeat that tells you if the current keydown was generated as a repeat from holding down the key. How could you modify the keydown handler to respond only to actual key presses, and not automatic repeats?
Solution
document.querySelector("html").addEventListener("keydown", event => {
if (!event.repeat) {
console.log(event);
}
return;
})
Top comments (0)