[英]JavaScript KeyDown event not triggered when multiple keys are held down
I am experiencing a strange problem with JavaScript. 我在JavaScript中遇到了一个奇怪的问题。 I am working on a HTML5 canvas game that uses keyboard input.
我正在使用键盘输入进行HTML5画布游戏。 The two player mode of the game involves up to 6 keys on the keyboard being pressed and held down.
游戏的两人游戏模式涉及最多按住键盘上的6个键。
It seems like the "keyDown" event stops being called after I hold 4 or 5 keys down on the keyboard. 按下键盘上的4或5个键后,似乎似乎不再调用“ keyDown”事件。
The code I am using is below: 我正在使用的代码如下:
window.onkeydown = function (event) {
console.log(event.keyCode);
input.onKeyDown(event.keyCode);
};
The console should log a key code for each key I press down. 控制台应该为我按下的每个键记录一个键代码。 However, it only seems to report the keycode for the first 4 or 5 I hold down.
但是,似乎只报告了我按住的前4或5个键码。 This is causing the controls for the two player version of my game to not work when both players press too many keys.
当两个玩家都按下太多键时,这会导致我的游戏的两个玩家版本的控件不起作用。
Is this a bug, a limitation of JavaScript/HTML5, or am I doing something wrong? 这是错误,是JavaScript / HTML5的限制,还是我做错了什么?
这是USB键盘的限制,而不是您的代码!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.