} c = keyStrokes.charAt(index); if(c == ']') {
   public String nextKeyStroke() {      String s = null;      boolean gotOne = false;      int start = index;      if(length > index) {         sb.setLength(0);         char c = keyStrokes.charAt(index);         switch(c) {            case '[':               sb.append(c);               index++;               // we need to throw an error here               if(index >= length) {                  System.out.println(" mnemonic key was incomplete :1 " +                                       "at position " + index);               }               else {                  c = keyStrokes.charAt(index);                  if(c == '[')                       index++;                  else {                     while(!gotOne) {                        if(c == ']') { // did we find an ending                           sb.append(c);                           index++;                           gotOne = true;                        }                        else {                           sb.append(c);                           index++;                           // we need to throw an error here because we did not                           //   find an ending for the potential mnemonic                           if(index >= length) {                              System.out.println(                              " mnemonic key was not not complete ending not found :2 " +                                          "at position " + index);                           }                           c = keyStrokes.charAt(index);                        }                     }                  }               }               break;            case ']':               index++;               if(index >= length) {                  System.out.println(                  " mnemonic key was not not complete ending not found :3 " +                              "at position " + index);               }               c = keyStrokes.charAt(index);               if(c == ']') {                  sb.append(c);                  index++;               }               else {                  System.out.println(                  " mnemonic key was not complete beginning not found :4 " +                              "at position " + index);               }               break;            default:               sb.append(c);               index++;               break;         }         if(sb != null) {            s = new String(sb);//            System.out.println("next before "+ keyStrokes + " " + start + " " + index + " " + length);            keyStrokes.delete(start,index);            index = 0;            length = keyStrokes.length();//            System.out.println("next before "+ keyStrokes + " " + start + " " + index + " " + length);         }      }//      System.out.println("next "+ keyStrokes);      return s;   }