I want to intercept the event "keypress" with javascript through the following code:
document.addEventListener("keypress", (e) => {
if (e.key === "a") {
console.log("You pressed the key a");
}
}
The code actually works. The problem is that even though I press the a letter once, the string "You press the key a" is printed in my console 40 times. It should be the behaviour of keydown, not keypress.