Aliases: 1x4 keypad, 4-key membrane keypad, membrane key strip, Adafruit 1332, the four-button strip in Elegoo's kits.
It is the 4x4 keypad cut down to a single row. There is no chip and no supply: under each key is a carbon pad that joins that key's line to the common line while you hold it, and nothing else.
Pins
The ribbon is not in key order. Counted from the end nearest key 1, the five pins of the real strip are:
| Ribbon pin | Mokxi pin | What it does |
|---|---|---|
| 1 | K2 |
Key 2. |
| 2 | K1 |
Key 1. |
| 3 | K4 |
Key 4. |
| 4 | K3 |
Key 3. |
| 5 | COM |
The common line every key closes onto. |
The drawing puts the pins in that same order, so a wire from the canvas goes where it would on the bench. Sources: Adafruit's product page for the strip (69 by 20 mm, 5-pin 0.1 inch connector) and the ArduinoGetStarted pinout; check yours with a meter, since clones are not always the same.
Reading it with Keypad.h
The Keypad library wants rows and columns, so give it one row, the common line, and four columns, the keys:
#include <Keypad.h>
const byte ROWS = 1;
const byte COLS = 4;
char keys[ROWS][COLS] = {{'1', '2', '3', '4'}};
byte rowPins[ROWS] = {2}; // COM
byte colPins[COLS] = {5, 6, 3, 4}; // keys 1, 2, 3 and 4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void loop() {
char key = keypad.getKey();
if (key) Serial.println(key);
}
The library pulls COM up, drives each key line low in turn and reads COM. The
pin numbers above are the five straight wires from the ribbon into pins 6 to 2,
which is why the keys land out of order.
You can skip the library too: put COM on GND, each key line on an
INPUT_PULLUP pin, and a held key reads LOW.
While it runs
Click a key to hold it down. Click the strip and the keys 1 to 4 on your
own keyboard press it. Escape hands the keyboard back to the canvas.
What the model gets right
A closed key is a real low-resistance contact between its line and COM, passing
whatever is on either side in either direction, the same model as the 4x4. Hold
several keys and every one of them closes. With only one row there is no rectangle
of keys, so unlike the bigger pads this strip cannot ghost. getKey() still hands
back only one key at a time, as on the bench; getKeys() and the key[] list read
up to ten at once.
What it does not model
Contact bounce: a key closes clean on the first edge. Keypad.h debounces anyway, so a sketch that works here works on the bench, but a hand-written loop with no debounce may count a press twice on a real strip.
The resistance a carbon pad picks up as it wears: a closed key here is always a clean, low-resistance contact.
Common mistakes
Wiring the ribbon in key order. Pin 1 is key 2, not key 1: a sketch that assumes 1-2-3-4 reads keys 1 and 2 swapped and 3 and 4 swapped.
Driving COM high and a key line low with no resistor in between. Leave the
scanning to Keypad.h, or use INPUT_PULLUP and GND as above.
See it in action
1x4 keypad strip: which key? is the strip on an Uno printing each key. Open it at /templates.