bl0b bl0b - 2 years ago 141
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download