Possible Duplicate:
Get Correct keyCode for keypad(numpad) keys
I'm writing an application that needs to be able to get the value of numbers pressed on the keyboard. I've come up with the following code:
var keyVal = "";
$(document).on("keydown.xRuleKey", function(e) {
var keyChar = String.fromCharCode(e.which);
if (!isNaN(keyChar)) {
keyVal += keyChar;
}
})
This works fine for the numbers on the top of the keyboard but when I use the numpad, the characters "`abcdefghi" are returned instead of "0123456789". Is this normal or is my keyboard weird? If it's normal is it safe to simply to set up a key/value pair to translate the letter to it's number equivelant or will that conflict with anything else. I don't think it will conflict with the regular letter keys as they return uppercase characters and the numpad returns lowercase.
Any thoughts? Anyone dealt with this before?