用于3个箭头键的JS document.onkeydown

问题描述 投票:0回答:1

我需要按住左箭头,然后按住右箭头,再按向上箭头。向上箭头不会被触发。

似乎是浏览器的某些限制或其他限制,我不确定,因为找不到有关此的任何信息。

document.onkeydown = checkKey;

function checkKey(e) {

  e = e || window.event;

  if (e.keyCode == '38') {
    console.log('up');
  } else if (e.keyCode == '40') {
    console.log('down');
  } else if (e.keyCode == '37') {
    console.log('left');
  } else if (e.keyCode == '39') {
    console.log('right');
  }

}
javascript onkeydown
1个回答
0
投票

这是键盘的限制。我尝试了另一种,但效果很好。

感谢@Thomas:

我的最佳猜测是这是您的键盘或其驱动程序的限制。 https://gaming.stackexchange.com/questions/6669/how-do-i-remove-the-limit-on-pc-keyboard-button-presses

© www.soinside.com 2019 - 2024. All rights reserved.