#Declaring an event handler and its functions

5 messages · Page 1 of 1 (latest)

zinc cloak
#

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?

vivid hinge
#

the first one doesnt work

zinc cloak
#

better?

mystic timber
#

you must use the first one if you plan to removeEventListener later. otherwise I would use the second

zinc cloak
#

I prefer to use the second as it seems like its easer to read and follow