0

I need to press and hold the left arrow, then the right arrow and then up arrow. The up arrow will not be triggered.

It looks like some restrictions of browser or something else, I'm not sure because can't find any information about that.

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');
  }

}
Shankar
  • 2,890
  • 3
  • 25
  • 40
Igosyee
  • 3
  • 2
  • maybe this will help: https://stackoverflow.com/questions/5203407/how-to-detect-if-multiple-keys-are-pressed-at-once-using-javascript – gugateider Nov 14 '19 at 14:36
  • 1
    My best guess is that it's a limitation of your keyboard or its driver. https://gaming.stackexchange.com/questions/6669/how-do-i-remove-the-limit-on-pc-keyboard-button-presses – Thomas Nov 14 '19 at 14:37
  • @Thomas, yeah, looks like keyboard limitations. Will try to find a man with 19-key rollover keyboard, and test then :D Thanks for the thought – Igosyee Nov 14 '19 at 14:43
  • Maybe if you listen to the on key up events and store which keys are down vs up you can make something that works. – Shimmy568 Nov 14 '19 at 16:01

1 Answers1

0

That's a keyboard limitation. I tried a different one, and it is working fine.

Thanks @Thomas for thought:

My best guess is that it's a limitation of your keyboard or its driver. https://gaming.stackexchange.com/questions/6669/how-do-i-remove-the-limit-on-pc-keyboard-button-presses

Igosyee
  • 3
  • 2