DEV Community

Discussion on: I put 18 event handlers on a React element

Collapse
 
qm3ster profile image
Mihail Malo

Some of those are really strange.
Eg if I hold backspace, it keeps counting keyDown but doesn't add even one keyPress. Whereas if I hold a letter key, it keeps spamming both?

Collapse
 
ma5ly profile image
Thomas Pikauli

I think the difference has to do with keyPress only registering actual characters like letters and numbers, while keyDown registers any key.

Collapse
 
qm3ster profile image
Mihail Malo

I feel like in both cases keyDown should fire once per physical press and then wait for keyUp before being able to fire again for this keycode. In nether case did it do that.

keyPress on the other hand can do whatever it damn pleases, including reacting only to characters appearing, I don't care :v