Reputation: 281
I tried to use the event.which and event.keyCode in my JavaScript code today and got a line ruled across each. I read that both have been deprecated on my VSCode.
Does anyone know the alternatives to them?
Upvotes: 0
Views: 982
Reputation: 131
event.keyCode
is deprecated , although some browsers do support it.
Use event.code
instead.
Read this on how to implement crossbrowser for complete support
Upvotes: 1
Reputation: 61
To determine what character corresponds with the key event, you need to use event.key instead. The events which/keyCode are indeed deprecated.
Cheers
Upvotes: 1