Question

I'm using the following code to detect a key being pressed:

$(document).keyup(function(event) { // the event variable contains the key pressed            
    if (event.which == x+65) { 
        alert(numToChar(x));
    }
});

"B" is keycode 66; however, it fires when i press "b", and alerts 66, which is the capital B keycode. little 'b' should alert "98"

I tried this in both firefox, and chrome.

No correct solution

OTHER TIPS

change the event to keypress if you want case sensitive keycodes.

$(document).keypress(function(event) { // the event variable contains the key pressed
   if (event.which == x+65) { 
      alert(numToChar(x));
   }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top