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?
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?
To determine what character corresponds with the key event, you need to use event.key instead. The events which/keyCode are indeed deprecated.
Cheers
event.keyCode
is deprecated , although some browsers do support it.
Use event.code
instead.
Read this on how to implement crossbrowser for complete support