Esp32 MacroPad error

Hi,
I am trying to make a macro pad with the DOIT ESP32 DEV KIT V1 using the BleKeyboard library for esp32

I have 10 push buttons if one of the 9 buttons are pressed then it sends a programmed keyboard shortcut but if any button if pressed while I am holding down button10 it would send a completely different shortcut

In my code when when I upload it to the esp32 I continuously get "Button 9 pressed, shortcut sent"

if anyone knows why this is happening please help, Thanks

#include <BleKeyboard.h>

BleKeyboard bleKeyboard;

const int buttonPin1 = 13;
const int buttonPin2 = 12;
const int buttonPin3 = 14;
const int buttonPin4 = 27;
const int buttonPin5 = 26;
const int buttonPin6 = 25;
const int buttonPin7 = 33;
const int buttonPin8 = 32;
const int buttonPin9 = 35;
const int buttonPin10 = 34;
const int buttonPin11 = 4;

bool buttonState1 = LOW;
bool buttonState2 = LOW;
bool buttonState3 = LOW;
bool buttonState4 = LOW;
bool buttonState5 = LOW;
bool buttonState6 = LOW;
bool buttonState7 = LOW;
bool buttonState8 = LOW;
bool buttonState9 = LOW;
bool buttonState10 = LOW;
bool buttonState11 = LOW;

void setup() {
  pinMode(buttonPin1, INPUT_PULLUP);
  pinMode(buttonPin2, INPUT_PULLUP);
  pinMode(buttonPin3, INPUT_PULLUP);
  pinMode(buttonPin4, INPUT_PULLUP);
  pinMode(buttonPin5, INPUT_PULLUP);
  pinMode(buttonPin6, INPUT_PULLUP);
  pinMode(buttonPin7, INPUT_PULLUP);
  pinMode(buttonPin8, INPUT_PULLUP);
  pinMode(buttonPin9, INPUT_PULLUP);
  pinMode(buttonPin10, INPUT_PULLUP);
  pinMode(buttonPin11, INPUT_PULLUP);

  Serial.begin(115200);
  Serial.println("Starting BLE work!");
  bleKeyboard.begin();
}

void loop() {
  if (bleKeyboard.isConnected()) {
    if (digitalRead(buttonPin1) == LOW && !buttonState1) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("a");
      Serial.println("Button 1 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      buttonState1 = true;
    } else if (digitalRead(buttonPin1) == LOW && !buttonState1) {
      buttonState1 = false;
    }

    if (digitalRead(buttonPin2) == LOW && !buttonState2) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("b");
      Serial.println("Button 2 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      buttonState2 = true;
    } else if (digitalRead(buttonPin2) == LOW && !buttonState2) {
      buttonState2 = false;
    }

    if (digitalRead(buttonPin3) == LOW && !buttonState3) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("c");
      Serial.println("Button 3 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      buttonState3 = true;
    } else if (digitalRead(buttonPin3) == LOW && !buttonState3) {
      buttonState3 = false;
    }

    if (digitalRead(buttonPin4) == LOW && !buttonState4) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("d");
      Serial.println("Button 4 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      buttonState4 = true;
    } else if (digitalRead(buttonPin4) == LOW && !buttonState4) {
      buttonState4 = false;
    }

    if (digitalRead(buttonPin5) == LOW && !buttonState5) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("e");
      Serial.println("Button 5 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      buttonState5 = true;
    } else if (digitalRead(buttonPin5) == LOW && !buttonState5) {
      buttonState5 = false;
    }

    if (digitalRead(buttonPin6) == LOW && !buttonState6) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("f");
      Serial.println("Button 6 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      buttonState6 = true;
    } else if (digitalRead(buttonPin6) == LOW && !buttonState6) {
      buttonState6 = false;
    }

    if (digitalRead(buttonPin7) == LOW && !buttonState7) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("g");
      Serial.println("Button 7 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      buttonState7 = true;
    } else if (digitalRead(buttonPin7) == LOW && !buttonState7) {
      buttonState7 = false;
    }

    if (digitalRead(buttonPin8) == LOW && !buttonState8) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("h");
      Serial.println("Button 8 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      buttonState8 = true;
      } else if (digitalRead(buttonPin8) == LOW && !buttonState8) {
      buttonState8 = false;}
    
    if (digitalRead(buttonPin9) == LOW && !buttonState9) {
      bleKeyboard.press(KEY_LEFT_ALT);
      bleKeyboard.print("i");
      Serial.println("Button 9 pressed, shortcut sent");
      bleKeyboard.releaseAll();
      delay(20);
      
      buttonState9 = true;
    } else if (digitalRead(buttonPin9) == LOW && !buttonState9) {
      buttonState9 = false;
    }
    if (digitalRead(buttonPin10) == LOW && !buttonState10) {
      if (digitalRead(buttonPin1) == LOW && !buttonState1) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("a");
          Serial.println("Button 1 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState1 = true;
        } else if (digitalRead(buttonPin1) == LOW && !buttonState1) {
          buttonState1 = false;
          
        }

        if (digitalRead(buttonPin2) == LOW && !buttonState2) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("b");
          Serial.println("Button 2 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState2 = true;
        } else if (digitalRead(buttonPin2) == LOW && !buttonState2) {
          buttonState2 = false;
        }

        if (digitalRead(buttonPin3) == LOW && !buttonState3) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("c");
          Serial.println("Button 3 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState3 = true;
        } else if (digitalRead(buttonPin3) == LOW && !buttonState3) {
          buttonState3 = false;
        }

        if (digitalRead(buttonPin4) == LOW && !buttonState4) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("d");
          Serial.println("Button 4 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState4 = true;
        } else if (digitalRead(buttonPin4) == LOW && !buttonState4) {
          buttonState4 = false;
        }

        if (digitalRead(buttonPin5) == LOW && !buttonState5) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("e");
          Serial.println("Button 5 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState5 = true;
        } else if (digitalRead(buttonPin5) == LOW && !buttonState5) {
          buttonState5 = false;
        }

        if (digitalRead(buttonPin6) == LOW && !buttonState6) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("f");
          Serial.println("Button 6 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState6 = true;
        } else if (digitalRead(buttonPin6) == LOW && !buttonState6) {
          buttonState6 = false;
        }

        if (digitalRead(buttonPin7) == LOW && !buttonState7) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("g");
          Serial.println("Button 7 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState7 = true;
        } else if (digitalRead(buttonPin7) == LOW && !buttonState7) {
          buttonState7 = false;
        }

        if (digitalRead(buttonPin8) == LOW && !buttonState8) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("h");
          Serial.println("Button 8 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState8 = true;
        } else if (digitalRead(buttonPin8) == LOW && !buttonState8) {
          buttonState8 = false;

        if (digitalRead(buttonPin9) == LOW && !buttonState9) {
          bleKeyboard.press(KEY_LEFT_ALT);
          bleKeyboard.print("i");
          Serial.println("Button 9 with 10 pressed, shortcut sent");
          bleKeyboard.releaseAll();
          delay(20);
          buttonState9 = true;
        } else if (digitalRead(buttonPin9) == LOW && !buttonState9) {
          buttonState9 = false;
        }
      buttonState10 = true;
    } else if (digitalRead(buttonPin10) == LOW && !buttonState10) {
      buttonState10 = false;
    }
    }
  }
}

Please check your circuit. Specially the button part. Check if the button is properly pulled up/down.

I checked my circuit and there was no problem with it I still get the message even if I disconnect the button from the esp32