'How to handle this deprecated event?

I'm a starter and not sure how I should write this piece of code properly, since 'event' seems deprecated.

input.addEventListener("keydown", () => {
   if (event.keyCode === 13) {
     event.preventDefault();
     button.click();
 }
 })


Solution 1:[1]

You missed an event in the callback

input.addEventListener("keydown", (event) => {
   if (event.keyCode === 13) {
     event.preventDefault();
     button.click();
   }
})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KONDRATJEV