Javascript 左右箭头键的键码是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2229335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-22 23:21:34 来源:igfitidea点击:
What are the key codes for the right and left arrow keys?
提问by ajsie
What are the key codes for the right and left arrow keys?
左右箭头键的键码是什么?
回答by Sampson
Left: 37, Right: 39.
左:37,右:39。
Discovery of other keycodes can be done with the following code:
可以使用以下代码发现其他键码:
$('body').keyup(function (event) {
console.log(event.keyCode);
});
Which will output the keycode to the console when you press any key.
当您按任意键时,它会将键码输出到控制台。
回答by rahul
left key - 37
左键 - 37
right key - 39
右键 - 39

