DEV Community

Chinwendu Agbaetuo
Chinwendu Agbaetuo

Posted on

JavaScript Quiz - Part 1

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?


document.querySelector("html").addEventListener("keydown", event => {
     if (!event.repeat) {

Enter fullscreen mode Exit fullscreen mode

Top comments (0)