MDN says that both keyCode
and which
are deprecated.
If both are deprecated, what is the proper way of getting the keycode.
Windows Forms provides two events that occur when a user presses a keyboard key and one event when a user releases a keyboard key: The KeyDown event occurs once. The KeyPress event, which can occur multiple times when a user holds down the same key.
Key codes are numeric values that correspond to physical keys on the keyboard but do not necessarily correspond to a particular character.
There are three types of keyboard events: keydown , keypress , and keyup .
The KeyboardEvent. code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key). In other words, this property returns a value that isn't altered by keyboard layout or the state of the modifier keys.
you are suposed to use "key" instead of "keyCode". problem is "key" is not yet implemented. so for now keep using "keyCode".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With