#Declaring an event handler and its functions
5 messages · Page 1 of 1 (latest)
5 messages · Page 1 of 1 (latest)
I'm sure this question is more opinion based.
document.addEventListener("keydown", eventHandler, false);
or
document.addEventListener("keydown", (e) => {
//insert handler function here
}, false);
Which one is more of the standard or does it matter?
the first one doesnt work
better?
you must use the first one if you plan to removeEventListener later. otherwise I would use the second
I prefer to use the second as it seems like its easer to read and follow