I'm developing a little game and I try to receive the key input from arrow up, down,left, right and space.
On keyDown i set some booleans to true und on keyDown to false again. In the main loop I check those booleans, so the character can move in 1 of 8 directions and shoot at the same time.
Everything works: North-East + Space, South-East + Space, South-West + Space but North-West + Space doesn't work. The event for the space bar doesn't get fired.
function onKeyDown(evt){
switch(evt.keyCode){
case up:
pressedUp=true;
break;
case right:
pressedRight = true;
break;
case down:
pressedDown = true;
break;
case left:
pressedLeft = true;
break;
case space:
spacePressed=true;
break;
}
updateCamera();
}
function onKeyUp(evt){
switch(evt.keyCode){
case up:
pressedUp=false;
break;
case right:
pressedRight = false;
break;
case down:
pressedDown = false;
break;
case left:
pressedLeft = false;
break;
case space:
spacePressed = false;
break;
}
}
I did some tests and I have the same behaviour throughout all browsers as well as in Flash and AIR applications, so for me it's very likely caused by my Keyboard (Model: Cherry JK-0100DE).
My workaround is to use another key instead of Space - probably going with X or Y.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With