Hi there!
I just programmed my first game in java, a space-invaders like game where you control a spaceship and fire at some astroide-whatevers.
I designed the keyboard input in the following manner, and everything works fine. The problem appears when I hold down the right- and the down-arrow keys and want to fire(press space) simultaneously: the fire-method is not called, allthough this works with all other combinations of arrow keys.
class MyKeyListener extends KeyAdapter {
public void keyPressed(KeyEvent ke) {
switch(ke.getKeyCode()) {
case KeyEvent.VK_RIGHT:
control.setRight(true);
control.setLeft(false); break;
case KeyEvent.VK_LEFT:
control.setLeft(true);
control.setRight(false); break;
case KeyEvent.VK_UP:
control.setUp(true);
control.setDown(false); break;
case KeyEvent.VK_DOWN:
control.setDown(true);
control.setUp(false); break;
case KeyEvent.VK_SPACE:
control.setFire(true);
fire();
break;
}
}
}
public void keyReleased(KeyEvent ke) {
switch(ke.getKeyCode()) {
case KeyEvent.VK_LEFT:
control.setLeft(false); break;
case KeyEvent.VK_RIGHT:
control.setRight(false); break;
case KeyEvent.VK_UP:
control.setUp(false); break;
case KeyEvent.VK_DOWN:
control.setDown(false); break;
case KeyEvent.VK_SPACE:
control.setFire(false); break;
}
}
}
}
I tried calling the fire()-method where I am working with the control.booleans for the movement of the ship, but hitting the spacebar with these two keys down seems to have no effect at all.
So my question is if anyone knows why it’s like that. Just a solution to the problem would also be satisfying to me 


