Note you ça make the code shorter
#include <Keypad_Matrix.h>
#include "Keyboard.h"
const byte rowPins[] = {A3, A2, A1, A0, 8, 9, 10};
const byte colPins[] = {4, 5, 6, 7};
const byte ROWS = sizeof rowPins / sizeof *rowPins;
const byte COLS = sizeof colPins / sizeof *colPins;
const char keys[ROWS][COLS] = {
{'E', '1', '2', '3'},
{'#', '4', '5', '6'},
{'*', '7', '8', '9'},
{'/', '-', '0', '+'},
{'R', 'C', '.', 'S'},
{'x', 'x', 'u', 'x'},
{'x', 'l', 'd', 'r'}
};
Keypad_Matrix kpd = Keypad_Matrix(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void keyDown(const char which)
{
Serial.print(which);
Serial.println(" BUTTON IS PRESSED");
switch (which) {
case 'E': Keyboard.press(KEY_ESC); break;
case 'R': Keyboard.press(KEY_RETURN); break;
case 'C': Keyboard.press(KEY_BACKSPACE); break;
case 'u': Keyboard.press(KEY_UP_ARROW); break;
case 'l': Keyboard.press(KEY_LEFT_ARROW); break;
case 'd': Keyboard.press(KEY_DOWN_ARROW); break;
case 'r': Keyboard.press(KEY_RIGHT_ARROW); break;
default: Keyboard.write(which); break;
}
delay(100);
Keyboard.releaseAll();
}
void setup() {
Serial.begin(115200); // no need to go slow
Serial.println("Starting.");
Keyboard.begin();
kpd.begin();
kpd.setKeyDownHandler(keyDown);
}
void loop() {
kpd.scan();
}
A state machine is likely a good approach b for handling multitap. Here is a small introduction to the topic: Yet another Finite State Machine introduction