please format code with </> button * homework policy * asking questions
I’m using the SHIFT and ALT keys as modifiers on mouse operations, but seem to be losing keyPressed events on the ALT key. Simple code example below. After hitting the ALT key a few dozen times, the ‘down’ count end up much less (about half) than the ‘up’ count.
The problem only seems to occur with the default JAVA2D renderer. P2D seems OK, but has other issues for me.
Any help much appreciated.
int sD, sU, aD, aU;
void setup() {
size(400, 200);
textSize(24);
}
void draw() {
background(0);
text(sU, 40, 40);
text(sD, 40, 80);
text(aU, 120, 40);
text(aD, 120, 80);
}
void keyPressed() {
if (key == CODED) {
switch (keyCode) {
case SHIFT: sD++; break;
case ALT : aD++; break;
default:
}
}
}
void keyReleased() {
if (key == CODED) {
switch (keyCode) {
case SHIFT: sU++; break;
case ALT: aU++; break;
default:
}
}
}