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));
}
});
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.
Pas de solution correcte
Autres conseils
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));
}
});