bl0b bl0b - 11 months ago 71
Javascript Question

Get key value of a key pressed

I don't find how to get the value of a key pressed.
I currently have


but it return '49' when I press on 1 instead of returning '1'.

Edit: I'm aware that Ascii code of key '1'.

The final goal is to allow people to only write digit into the input. So i want to detect the non digit and not display them.


As it's told in comment it's ASCII code. To get it as character you can do: