I have a beginner's question on JavaScript: In a small testing script I oberserved that some key-events seemingly do not trigger when others are already triggered. In other words: If some keys are down, most of the other keydown-events are kind of blocked. For example holding down keys a, s, d, f, g do not trigger the keydown-event for g. However, If I am holding e.g. h and j down, too, their keydown-event is triggered as expected.
For this test I've used Mozilla Firefox 26.0 on Windows 7 Home Edition 64-Bit.
Here is the included JavaScript file which is used to output the map of key-events with keydown-type to some div-element with id "testout001"
:
var keyMap = [];
function keyMapToHTML(arr){
var i = 0;
var temp = "";
while(i<arr.length){
if(arr[i]){
temp += i + "<br>";
}
i++;
}
return temp;
}
function keyHandler(e){
e = e || event; // deal with IE
keyMap[e.keyCode] = (e.type == 'keydown');
document.getElementById("testout001").innerHTML = keyMapToHTML(keyMap);
}
- First of all: Is this a bug?
- Why are certain keydown-combinations working while others won't?
- Are there limits (most likely browser-specific) to how many keys can be hold down/pressed at the same time?
Thank you in advance for your suggestions!