我使用以下代码来检测按键被按下的情况:
$(document).keyup(function(event) { // the event variable contains the key pressed
if (event.which == x+65) {
alert(numToChar(x));
}
});
"b“是键码66;但是,当我按下"B”时它就会触发,并提示66,这是大写的B键码。小“b”应警示"98“
我在火狐和chrome上都试过了。
发布于 2013-10-10 18:18:14
如果您想要区分大小写的键代码,请将事件更改为keypress。
$(document).keypress(function(event) { // the event variable contains the key pressed
if (event.which == x+65) {
alert(numToChar(x));
}
});
https://stackoverflow.com/questions/19303196
复制相似问题