I am using the following code to determine which key is pressed by the user.
$(document).keydown(function(e){
var code = (e.keyCode? e.keyCode : e.charCode);
$("#keyCode").html("Key Code: " + code);
});
My problem is that the code for +/= key is the same as the code for the numpad plus key. Both are 107. How can I tell which of these two keys were pressed?
Update
It looks like this problem is specific to Firefox. Chrome and IE give me codes of 107 and 187.
The only way I could get this to work properly in Firefox was to use the keypress event and get the charCode. I also keep track of if the Shift key is held down.