I want to be able to press control, record it in a boolean, and then press "s" (or another letter key) and do something if control is also pressed. Simple example:
- boolean ctrl = false;
boolean shft = false;
void setup() {}
void draw() {}
void keyPressed() {
if (key == CODED) {
if (keyCode == CONTROL) ctrl = true;
if (keyCode == SHIFT) shft = true;
}
else {
println("ctrl:" + ctrl + " shift:" + shft);
println(key);
}
}
void keyReleased() {
if (key == CODED) {
if (keyCode == CONTROL) ctrl = false;
if (keyCode == SHIFT) shft = false;
}
}
If you press Control and then "s", it prints a box-thing instead of "s", and (key == 's') resolves to false. Shift does not cause any problems (it capitalizes the letter, obviously). What am I doing wrong?
In case it's relevant: 32bit Ubuntu on a Thinkpad T430.
In case it's relevant: 32bit Ubuntu on a Thinkpad T430.
1