Matrix Button Multiple Buton Press

Arduino doesnt read the next buttons while the first button is pressed. Code is ;

#include <Keypad.h>
#include <Keyboard.h>


#define ENABLE_PULLUPS
#define NUMROTARIES 2
#define NUMBUTTONS
#define NUMROWS 5
#define NUMCOLS 5



char buttons[NUMROWS][NUMCOLS] = {
  {'a', 'b', 'c', 'd'},
  {'e', 'f', 'g', 'h'},
  {'i', 'j', 'k', 'l'},
  {'m', 'n', 'o', 'p'},
  {'q', 'r', 's', 't'}

};

struct rotariesdef {
  byte pin1;
  byte pin2;
  int ccwchar;
  int cwchar;
  volatile unsigned char state;
};
rotariesdef rotaries[NUMROTARIES] {
  {0, 1, 'u', 'v',},
  {2, 3, 'w', 'x',},
};

#define led4 A4
#define led0 A0
#define led1 A1
#define led2 A2
#define led3 A3
#define led5 A5



#define DIR_CCW 0x10
#define DIR_CW 0x20

#define R_START 0x0
#define R_CW_FINAL 0x1
#define R_CW_BEGIN 0x2
#define R_CW_NEXT 0x3
#define R_CCW_BEGIN 0x4
#define R_CCW_FINAL 0x5
#define R_CCW_NEXT 0x6


boolean ledA0_state;
boolean ledA1_state;
boolean ledA2_state;
boolean ledA3_state;
boolean ledA4_state;
boolean ledA5_state;

unsigned long loopCount;
unsigned long startTime;
String msg;

const unsigned char ttable[7][4] = {
  // R_START
  {R_START,    R_CW_BEGIN,  R_CCW_BEGIN, R_START},
  // R_CW_FINAL
  {R_CW_NEXT,  R_START,     R_CW_FINAL,  R_START | DIR_CW},
  // R_CW_BEGIN
  {R_CW_NEXT,  R_CW_BEGIN,  R_START,     R_START},
  // R_CW_NEXT
  {R_CW_NEXT,  R_CW_BEGIN,  R_CW_FINAL,  R_START},
  // R_CCW_BEGIN
  {R_CCW_NEXT, R_START,     R_CCW_BEGIN, R_START},
  // R_CCW_FINAL
  {R_CCW_NEXT, R_CCW_FINAL, R_START,     R_START | DIR_CCW},
  // R_CCW_NEXT
  {R_CCW_NEXT, R_CCW_FINAL, R_CCW_BEGIN, R_START},
};


byte rowPins[NUMROWS] = {4, 5, 6, 7, 8,};
byte colPins[NUMCOLS] = {9, 10, 11, 12,};

Keypad buttbx = Keypad( makeKeymap(buttons), rowPins, colPins, NUMROWS, NUMCOLS);


void setup() {

  pinMode(led1, OUTPUT);
  pinMode(led0, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);


  digitalWrite(led3, HIGH);
  digitalWrite(led0, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led1, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH);
  delay(500);

  digitalWrite(led3, LOW);
  digitalWrite(led0, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led1, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH);

  Keyboard.begin();
  rotary_init();
}
void loop() {

  CheckAllEncoders();

  CheckAllButtons();
}
void CheckAllButtons(void) {
  char key = buttbx.getKey();

  if (key == 'a')  {
    Keyboard.write('a');
    delay(150);
    Keyboard.release('a');
    digitalWrite(led0, !digitalRead(led0));

  }
  if (key == 'b')  {
    Keyboard.write('b');
    delay(150);
    Keyboard.release('b');
  }
  if (key == 'c')  {
    Keyboard.write('c');
    delay(150);
    Keyboard.release('c');
    digitalWrite(led3, !digitalRead(led3));
  }
  if (key == 'g') {
    Keyboard.write('g');
    delay(150);
    Keyboard.release('g');
    digitalWrite(led1, !digitalRead(led1));
  }
  if (key == 'h')  {
    Keyboard.write('h');
    delay(150);
    Keyboard.release('h');
    digitalWrite(led2, !digitalRead(led2));
  }
  if (key == 'k')  {
    Keyboard.write('k');
    delay(150);
    Keyboard.release('k');
    digitalWrite(led4, !digitalRead(led4));
  }
  if (key == 'o')  {
    Keyboard.write('o');
    delay(150);
    Keyboard.release('o');
  }
  if (key == 's')  {
    Keyboard.write('s');
    delay(150);
    Keyboard.release('s');

  }
}

void rotary_init() {
  for (int i = 0; i < NUMROTARIES; i++) {
    pinMode(rotaries[i].pin1, INPUT);
    pinMode(rotaries[i].pin2, INPUT);
#ifdef ENABLE_PULLUPS
    digitalWrite(rotaries[i].pin1, HIGH);
    digitalWrite(rotaries[i].pin2, HIGH);
#endif
  }
}

unsigned char rotary_process(int _i) {
  unsigned char pinstate = (digitalRead(rotaries[_i].pin2) << 1) | digitalRead(rotaries[_i].pin1);
  rotaries[_i].state = ttable[rotaries[_i].state & 0xf][pinstate];
  return (rotaries[_i].state & 0x30);
}



void CheckAllEncoders(void) {
  for (int i = 0; i < NUMROTARIES; i++) {
    unsigned char result = rotary_process(i);
    if (result) {
      Keyboard.write(result == DIR_CCW ? rotaries[i].ccwchar : rotaries[i].cwchar );


      if (rotaries[i].ccwchar == 'u') {
        digitalWrite(led5, LOW);
        delay(50);
        digitalWrite(led5, HIGH);
        delay(50);
      }
      if (rotaries[i].ccwchar == 'w') {
        digitalWrite(led5, LOW);
        delay(50);
        digitalWrite(led5, HIGH);
        delay(50);
      }
    }
  }
}

The following code is very good working. All buttons are being read but I can't add leds to the buttons.

#include <Keyboard.h>


// Array of pins for the columns
int cPins[] = {2, 3, 4, 5, 6};

// Number of pins in the column array
int cPinsNo = 5;

// Array of pins for the rows
int rPins[] = {8, 9, 10, 11};

// Number of pins in the row array
int rPinsNo = 4;

// Array for the last known switch states [cPinsNo][rPinsNo]
int colPrev[5][4] = {0};


uint8_t buttonCodes[5][4] = {
  {0x61, 0x62, 0x63, 0x64},
  {0x65, 0x66, 0x67, 0x68},
  {0x69, 0x70, 0x71, 0x72},
  {0x73, 0x74, 0x75, 0x76},
  {0x77, 0x78, 0x79, 0x7A}
};

void setup()
{
 
  Serial.begin(9600);




  for(int cPin = 0; cPin < cPinsNo; cPin++)
  {
    pinMode(cPins[cPin], OUTPUT);
    digitalWrite(cPins[cPin], HIGH);
  }

 

  for(int rPin = 0; rPin < rPinsNo; rPin++)
  {
    pinMode(rPins[rPin], INPUT);
    digitalWrite(rPins[rPin], HIGH);
  }

} 

void loop()
{
  // Loop through the columns
  for(int cPin = 0; cPin < cPinsNo; cPin++)
  {
    digitalWrite(cPins[cPin], LOW);

    // Loop through the rows
    for(int rPin = 0; rPin < rPinsNo; rPin++)
    {
    
      if(digitalRead(rPins[rPin]) == LOW)
      {
        
        if(colPrev[cPin][rPin] == 0)
        {
         
        

          Keyboard.press(buttonCodes[cPin][rPin]);
          delay(150);
          Keyboard.release(buttonCodes[cPin][rPin]); 

   
          colPrev[cPin][rPin] = 1;
        }
      } 
      else {

       
        if(colPrev[cPin][rPin] == 1)
        {
         
       
          colPrev[cPin][rPin] = 0;
        }
      }
    }
    digitalWrite(cPins[cPin], HIGH);
  }
}

what do i need to do for the first code to work properly?

Sorry for my bad english. I hope I have written correctly

Arduino doesnt read the next buttons while the first button is pressed.

Well, of course not, because as soon as you see that a key is pressed, you call the stickHeadInSand() method (spelled delay). Stop doing that.

All buttons are being read but I can't add leds to the buttons.

Why can't you?

PaulS:
Well, of course not, because as soon as you see that a key is pressed, you call the stickHeadInSand() method (spelled delay). Stop doing that.
Why can't you?

I tried but I could not. Leds always stay in off or on mode.

How should i do one of the two or something else you know? I finished making the box, only code left. There was no toggle switch in the box before, I have now added a toggle switch to the box so it is not working properly.

I added the picture of the box.