Character-based key detection can only be performed with an event keypress:
$(document).keypress(function(e) {
var charCode = e.which;
if (charCode) {
var lowerCharStr = String.fromCharCode(charCode).toLowerCase();
if (lowerCharStr == "h") {
$('.something').show();
} else if (lowerCharStr == "j") {
$('.something').hide();
}
}
});
source
share