Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the proper way of getting the keyCode from a keyboard event

Tags:

javascript

MDN says that both keyCode and which are deprecated.

If both are deprecated, what is the proper way of getting the keycode.

like image 384
Francisc Avatar asked Jan 20 '14 15:01

Francisc


People also ask

When a key from keyboard is released which event gets generated?

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.

What is KeyCode in keyboard?

Key codes are numeric values that correspond to physical keys on the keyboard but do not necessarily correspond to a particular character.

What is the order of events when a key is typed?

There are three types of keyboard events: keydown , keypress , and keyup .

What is a key event in coding?

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.


1 Answers

you are suposed to use "key" instead of "keyCode". problem is "key" is not yet implemented. so for now keep using "keyCode".

like image 177
Marcelo Biffara Avatar answered Sep 28 '22 11:09

Marcelo Biffara