简体   繁体   English

JS键码与网站说的不一样吗?

[英]JS keycodes not the same as websites say?

When I look onto any website that shows JS keycodes, I see that the f# buttons are 112-123, and that 's' is 83. However, I made my website console.log() the keycode of the key I press, and 's' came up as 115. The f# keys don't show up at all. 当我查看显示JS密钥代码的任何网站时,我看到f#按钮为112-123,即为83。但是,我将我的网站console.log()设为了我按下的键的密钥, “ s”显示为115。f#键根本不显示。 Can someone please help? 有人可以帮忙吗?

Code is just 代码只是

body.addEventListener('keypress', function() {
   var x = event.keyCode;
   console.log(x);
});

You need to consider upper and lower case. 您需要考虑大小写。 S is 83. s is 115. S是83. s是115。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM