Retrieve user input value from keydown
I was using this line of code to get the user entered value on keypress event 

     var number = String.fromCharCode(e.which);

This gives the incorrect (not the value entered for instance if use presses the number 2 I want the value of 2) value for keydown. I have to use keydown functionality in the current project I am working on. How do I get the value for the user input on keydown?
Retrieve user input value from keydown
===

I was using this line of code to get the user entered value on keypress event 

     var number = String.fromCharCode(e.which);

This gives the incorrect (not the value entered for instance if use presses the number 2 I want the value of 2) value for keydown. I have to use keydown functionality in the current project I am working on. How do I get the value for the user input on keydown?