I want to be able to listen to multiple button presses, like so:
$("#body").keypress(function(event) {
if (event.which == 49) { //1
//do something
}
if (event.which == 68) { //d
//do something else
}
});
But I’m not able to intercept the “d” keypress. Any advice?
Cheers
You could use a switch statement, permitting 100 (lowercase ‘d’) to fall through to 68 (uppercase ‘D’):
Fiddle: http://jsfiddle.net/jonathansampson/CJKUh/