JavaScript Quiz - Part 1

dindustack

Chinwendu Agbaetuo

Posted on April 17, 2024

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?

Solution

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

    return;
})
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
dindustack
Chinwendu Agbaetuo

Posted on April 17, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related