How to handle user input

Interesting. In version 3 strings were not supported in switch. I have used a work-around, functions as a switch but also allows the use of variables in the case equivalent.

void setup(){
  String[] x= {"A","B","Z",str(TAB),"V"};
  String somethingVariable= "Q";
  
  for( String a:x){
  print(a+": ");  
  commandLoop:
    {
      if( a.equals("A") ){
        // handle command A
        println("command A");
        break commandLoop;
      }
      
      if( a.equals("B") ){
        // handle command B
        println("command B");
        break commandLoop;
      }
      
      if( a.equals("Z") ){
        // handle command Z
        println("command Z");
        break commandLoop;
      }

      if( a.equals(str(TAB)) ){
        // handle command TAB
        println("command TAB");
        break commandLoop;
      }
      
      if( a.equals(somethingVariable) ){
        // handle command somethingVariable
        println("command somethingVariable",somethingVariable);
        break commandLoop;
      }
      
      // default
      println("command",a,"unknown");
      
    } // end commandLoop

}