is there a way to 'for loop' switch? Trying to set up 50+ boolean toggles for the keyboard

edited August 2018 in Questions about Code

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

Tagged:

Answers

Sign In or Register to comment.