Keypad delay while pressing different keys

Hi, I'm trying to build keyboard, using keypad.h's matrix scan.
It works great but delay while pressing other key are quite significant.
Pressing single key rapidly has no problem, only when I press one and press the other, second one is ignored if press too fast.
Is it normal to have this problem while using keypad.h's matrix? or Is my code wrong?
I'm using teensy 4.0

#include <Keypad.h>
#include <usb_keyboard.h>

int longpressdelay = 350;
int spamspeed = 15;

const byte ROWS = 6;   //four rows
const byte COLS = 17;  //four columns

//define the cymbols on the buttons of the keypads
const uint8_t layout[6][17] = {
  {104 ,41  ,41  ,58  ,59  ,60  ,61  ,62  ,63  ,64  ,65  ,66  ,67  ,68  ,69  ,73  ,74 },
  {105 ,21  ,53  ,30  ,31  ,32  ,33  ,34  ,35  ,36  ,37  ,38  ,39  ,45  ,46  ,42  ,77 },
  {106 ,21  ,43  ,20  ,26  ,8   ,21  ,23  ,28  ,24  ,12  ,18  ,19  ,47  ,48  ,49  ,76 },
  {107 ,21  ,57  ,4   ,22  ,7   ,9   ,10  ,11  ,13  ,14  ,15  ,51  ,52  ,0   ,40  ,75 },
  {108 ,21  ,0x02,29  ,27  ,6   ,25  ,5   ,17  ,16  ,54  ,55  ,56  ,0   ,0x20,82  ,78 },
  {109 ,21  ,0x01,0x08,0x04,0   ,0   ,44  ,0   ,0   ,0   ,0x40,0x80,0   ,80  ,81  ,79 }
};

byte rowPins[ROWS] = { 0, 1, 2, 3, 4, 5 };                                                //connect to the row pinouts of the keypad
byte colPins[COLS] = { 6, 7, 8, 9, 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 34 };  //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad(makeKeymap(layout), rowPins, colPins, ROWS, COLS);

void setup() {
  Keyboard.begin();
  customKeypad.setDebounceTime(10);
}


long oldPosition = -999;

void loop() {
  char customKey = customKeypad.getKey();

  if (customKey) {
    usb_keyboard_press(customKey,0);
  }
}

I checked with multimeter and it is getting low properly but no key is printed

The Keypad library only supports 16 columns

The getKey() method is just for single key strokes. If you want to react on multiple pressed keys you have to use getKeys() instead and then use the "key" array to check all pressed keys.

1 Like

Thank you. I searched with your reply and found this.

https://forum.arduino.cc/t/keypad-h-multiple-keypress-issues/694339

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.