We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is this is possible without writing out the switch command for every key...?
the below is an example of what im trying to achieve but I get an error when I change the 'case' for 108 to m....
in this example pressing the 'l' key toggles true or false and prints this
boolean keyT[] = new boolean [128];
void draw() {
}
void keyPressed() {
int m = key;
switch(m) {
case 108:
keyT[m] = !keyT[m];
println(keyT[m], m);
break;
}
}
cheers Rich
Answers
NEW FORUM: https://discourse.processing.org/
Just use a for loop and skip the switch statement.
http://Studio.ProcessingTogether.com/sp/pad/export/ro.9cfU11egvzT6G
If you want to treat each key as a switch, you might also be interested in this boolean toggle keyboard that uses a HashMap:
https://forum.processing.org/two/discussion/comment/122623/#Comment_122623
In tfguy Solution the for loop is not necessary just use m as index for array
:-$ 8-} ~X( ^:)^
;-)
cheers for all the info guys!! got both toggles and key presses setup and works a dream - will post code later :)