Keypad query

Hello, Please see my code below. I would like to know if it is possible rather than write 128 if statements for each of my key actions to do a something that will match the key value to the key action in an easy way? The key action numbers represent the values of each key so if the code can do an auto check they run the next command to send the key action information onto the next function to sedn the OSC message, hope that makes sense.

#include <Keypad.h>

const byte ROWS = 8; //four rows
const byte COLS = 16; //three columns
char keys[ROWS][COLS] =
{
  {'a' - '_', 'a' - '^', 'a' - ']', 'a' - '[', 'a' - 'Z', 'a' - 'Y', 'a' - 'X', 'a' - 'W', 'a' - 'V', 'a' - 'U', 'a' - 'T', 'a' - 'S', 'a' - 'R', 'a' - 'Q', 'a' - 'P', 'a' - 'O'},
  {'a' - 'N', 'a' - 'M', 'a' - 'L', 'a' - 'K', 'a' - 'J', 'a' - 'I', 'a' - 'H', 'a' - 'G', 'a' - 'F', 'a' - 'E', 'a' - 'D', 'a' - 'C', 'a' - 'B', 'a' - 'A', '!', '"'},
  {'#', '

, ‘%’, ‘&’, ‘(’, ‘)’, ‘*’, ‘+’, ‘,’, ‘-’, ‘.’, ‘/’, ‘0’, ‘1’, ‘2’, ‘3’},
  {‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘:’, ‘;’, ‘<’, ‘=’, ‘>’, ‘?’, ‘@’, ‘A’, ‘B’, ‘C’},
  {‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’},
  {‘T’, ‘U’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’, ‘[’, ‘]’, ‘^’, ‘_’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’},
  {‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’},
  {‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘{’, ‘}’, ‘~’, ‘a’ - ‘b’, ‘a’ - ‘c’, ‘a’ - ‘d’, ‘a’ - ‘e’, ‘a’ - ‘f’, ‘a’ - ‘g’, ‘a’ - ‘h’, ‘a’ - ‘i’}
};
byte rowPins[ROWS] = {25, 27, 29, 31, 33, 35, 37, 39}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52}; //connect to the column pinouts of the kpd

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

unsigned long loopCount;
unsigned long startTime;
int keyPress;
int state;
String eosKey;
String eosMsg;

const String EOS_KEY = “/eos/key/”;

//Key Actions

const String EOS_KEY_02 = “MACRO/901”;
const String EOS_KEY_03 = “MACRO/902”;
const String EOS_KEY_19 = “MACRO/903”;
const String EOS_KEY_20 = “MACRO/904”;
const String EOS_KEY_35 = “MACRO/905”;
const String EOS_KEY_36 = “MACRO/906”;
const String EOS_KEY_52 = “MACRO/907”;
const String EOS_KEY_53 = “MACRO/908”;
const String EOS_KEY_68 = “MACRO/909”;
const String EOS_KEY_69 = “MACRO/910”;
const String EOS_KEY_84 = “MACRO/911”;
const String EOS_KEY_85 = “MACRO/912”;
const String EOS_KEY_102 = “BACK”;
const String EOS_KEY_103 = “BACK”;
const String EOS_KEY_118 = “GO”;
const String EOS_KEY_119 = “GO”;

const String EOS_KEY_04 = “DISPLAYS”;
const String EOS_KEY_06 = “ADDRESS”;
const String EOS_KEY_07 = “??”;
const String EOS_KEY_09 = “SOFTKEY1”;
const String EOS_KEY_10 = “SOFTKEY2”;
const String EOS_KEY_11 = “SOFTKEY3”;
const String EOS_KEY_12 = “SOFTKEY4”;
const String EOS_KEY_13 = “SOFTKEY5”;
const String EOS_KEY_14 = “SOFTKEY6”;
const String EOS_KEY_15 = “MORE_SOFTKEYS”;
const String EOS_KEY_16 = “LIVE”;
const String EOS_KEY_17 = “BLIND”;
const String EOS_KEY_18 = “?”;

const String EOS_KEY_21 = “MACRO”;
const String EOS_KEY_22 = “HELP”;
const String EOS_KEY_23 = “LEARN”;
const String EOS_KEY_37 = “DELETE”;
const String EOS_KEY_38 = “??”;
const String EOS_KEY_40 = “EFFECT”;

const String EOS_KEY_54 = “PART”;
const String EOS_KEY_55 = “CUE”;
const String EOS_KEY_56 = “RECORD”;
const String EOS_KEY_70 = “INTENSITY_PALETTE”;
const String EOS_KEY_71 = “FOCUS_PALETTE”;
const String EOS_KEY_72 = “RECORD_ONLY”;
const String EOS_KEY_86 = “COLOR_PALETTE”;
const String EOS_KEY_87 = “BEAM_PALETTE”;
const String EOS_KEY_88 = “UPDATE”;
const String EOS_KEY_104 = “PRESET”;
const String EOS_KEY_105 = “SUB”;
const String EOS_KEY_106 = “GROUP”;
const String EOS_KEY_120 = “SHIFT”;
const String EOS_KEY_121 = “DELAY”;
const String EOS_KEY_122 = “TIME”;

const String EOS_KEY_25 = “QUERY”;
const String EOS_KEY_26 = “COPY_TO”;
const String EOS_KEY_27 = “RECALL_FROM”;
const String EOS_KEY_42 = “GO_TO_CUE”;
const String EOS_KEY_43 = “??”;
const String EOS_KEY_44 = “BLOCK”;

const String EOS_KEY_58 = “PLUS”;
const String EOS_KEY_59 = “THRU”;
const String EOS_KEY_60 = “MINUS”;
const String EOS_KEY_74 = “7”;
const String EOS_KEY_75 = “8”;
const String EOS_KEY_76 = “9”;
const String EOS_KEY_90 = “4”;
const String EOS_KEY_91 = “5”;
const String EOS_KEY_93 = “6”;
const String EOS_KEY_108 = “1”;
const String EOS_KEY_109 = “2”;
const String EOS_KEY_110 = “3”;
const String EOS_KEY_125 = “CLEAR”;
const String EOS_KEY_126 = “0”;
const String EOS_KEY_ - 1 = “.”;

const String EOS_KEY_28 = “LABEL”;
const String EOS_KEY_29 = “??”;
const String EOS_KEY_30 = “ABOUT”;
const String EOS_KEY_45 = “UNDO”;
const String EOS_KEY_46 = “HIGHLIGHT”;
const String EOS_KEY_47 = “FAN”;

const String EOS_KEY_61 = “SLASH”;
const String EOS_KEY_62 = “MARK”;
const String EOS_KEY_63 = “SNAEK”;
const String EOS_KEY_77 = “REM_DIM”;
const String EOS_KEY_78 = “PLUS10”;
const String EOS_KEY_79 = “HOME”;
const String EOS_KEY_94 = “OUT”;
const String EOS_KEY_95 = “MINUS10”;
const String EOS_KEY_96 = “TRACE”;
const String EOS_KEY_111 = “FULL”;
const String EOS_KEY_112 = “LEVEL”;
const String EOS_KEY_113 = “Q_ONLY_TRACK”;
const String EOS_KEY_ - 2 = “AT”;
const String EOS_KEY_ - 3 = “ENTER”;
const String EOS_KEY_ - 4 = “ENTER”;

const String EOS_KEY_31 = “PARK”;
const String EOS_KEY_48 = “CAPTURE”;

const String EOS_KEY_64 = “SELECT_LAST”;
const String EOS_KEY_80 = “SELECT_MANUAL”;
const String EOS_KEY_97 = “SELECT_ACTIVE”;
const String EOS_KEY_114 = “LAST”;
const String EOS_KEY_ - 5 = “NEXT”;

const String EOS_KEY_32 = “ESCAPE”;
const String EOS_KEY_33 = “PAGE_UP”;
const String EOS_KEY_34 = “SELECT”;
const String EOS_KEY_49 = “PAGE_LEFT”;
const String EOS_KEY_50 = “PAGE_DOWN”;
const String EOS_KEY_51 = “PAGE_RIGHT”;

const String EOS_KEY_65 = “SHEET”;
const String EOS_KEY_66 = “FLEXI_MODE”;
const String EOS_KEY_67 = “TIME”;
const String EOS_KEY_81 = “FORMAT”;
const String EOS_KEY_82 = “EXPAND”;
const String EOS_KEY_83 = “DATA”;

/*
  const String EOS_KEY_99 = “??”;
  const String EOS_KEY_100 = “??”;
  const String EOS_KEY_101 = “??”;
  const String EOS_KEY_115 = “??”;
  const String EOS_KEY_116 = “??”;
  const String EOS_KEY_117 = “??”;
  const String EOS_KEY_-6 = “??”;
  const String EOS_KEY_-7 = “??”;
  const String EOS_KEY_-8 = “??”;
*/

void sendKeyPress(bool down, String key)  //Send OSC message to EOS
{
  key = EOS_KEY + key;
  Serial.print(key);
  Serial.print(" ");
  Serial.println(down);

//OSCMessage keyMsg(key.c_str());
  /*
    if (down)
      keyMsg.add(EDGE_DOWN);
    else
      keyMsg.add(EDGE_UP);
  */
}

void KeyPress(int keyNum, int state) // Assign action to key# & state#
{
  Serial.print(keyNum);
  Serial.print(" ");
  Serial.println(state);

/*
    if (keyNum == 98)
    {
    if (state == “1”)
    {
      sendKeyPress(false, EOS_KEY_01);
    }
    else
    {
      sendKeyPress(true, EOS_KEY_01);
    }
    }

if (keyNum == 99) {
    if (state == “1”)
    {
      sendKeyPress(false, EOS_KEY_02);
    }
    else
    {
      sendKeyPress(true, EOS_KEY_02);
    }
    }

if (keyNum == 100) {
    Serial.print(“Key 3 pressed do this”);
    Serial.print(" “);
    Serial.println(state);
    }
    if (keyNum == 101) {
    Serial.print(“Key 4 pressed do this”);
    Serial.print(” ");
    Serial.println(state);
    }
  */
}

void checkKeys()  //Check keys
{
  if (kpd.getKeys())
  {
    for (int i = 0; i < LIST_MAX; i++) // Scan the whole key list.
    {
      if ( kpd.key[i].stateChanged )  // Only find keys that have changed state.
      {
        switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
          case PRESSED:
            state = “1”; // Set state to PRESSED
            KeyPress(kpd.key[i].kchar, state); // Call KeyPress function with key & state values
            break;
          case RELEASED:
            state = “2”; // Set state to RELEASED
            KeyPress(kpd.key[i].kchar, state); // Call KeyPress function with key & state values
            break;
        }
      }
    }
  }
}

void setup() {
  Serial.begin(9600);
  loopCount = 0;
  startTime = millis();
}

void loop() //Main Loop
{
  loopCount++;
  if ( (millis() - startTime) > 5000 ) {
    //Serial.print("Average loops per second = ");
    //Serial.println(loopCount/5);
    startTime = millis();
    loopCount = 0;
  }

checkKeys();

}  // End loop

A switch statement could work, but better still might be an array and a loop. I am tempted to give you an example but I don't really understand what you are trying to accomplish.

You already know that the compiler doesn't read comments. We only read them for the laughs, as they're usually wrong.

It appears you may be asking a question related to the code which is currently commented out. My response is "That commented section does nothing because it's a comment."