Tracking three (specific) keystrokes
in
Programming Questions
•
1 year ago
Hey, all. It's my first post here on the forum, and I've only been working with processing for a few weeks now, but I'm having a bit of trouble tracking three keystrokes.
As with most high-schoolers, one of the things I want to program most is a functional game, and the following is a code fragment picking up on keystrokes:
void keyPressed() {
if (key == CODED) {
if (keyCode == UP) {
player.thrust = true;
player.fOB = true;
} else if (keyCode == LEFT) {
player.turn = true;
player.lOR = true;
} else if (keyCode == RIGHT) {
player.turn = true;
player.lOR = false;
}
}
}
void keyReleased() {
if (key == CODED) {
if (keyCode == UP) {
player.thrust = false ;
} else if (keyCode == LEFT || keyCode == RIGHT) {
player.turn = false;
}
}
if (keyCode == ' ') {
player.fire();
}
}
The following key combinations work:
UP+RIGHT
UP+LEFT
space+RIGHT
space+UP
space+LEFT
UP+RIGHT+space...
But UP+LEFT+space doesn't work. What's wrong here?
1