简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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