# Matrix multitap keypad

**URL:** <https://forum.arduino.cc/t/matrix-multitap-keypad/1431545>\
**Category:** General Guidance\
**Created:** [February 18, 2026, 8:06pm UTC](https://forum.arduino.cc/t/matrix-multitap-keypad/1431545 "2026-02-18T20:06:13Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [February 19, 2026, 6:50am UTC](https://forum.arduino.cc/t/matrix-multitap-keypad/1431545/3 "2026-02-19T06:50:13Z")

</div>

Note you ça make the code shorter

```arduino
#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](https://forum.arduino.cc/t/yet-another-finite-state-machine-introduction/1198997)

---

_[View the full topic](https://forum.arduino.cc/t/matrix-multitap-keypad/1431545)._
