Source: https://mokxi.com/parts/keypad
Updated: 2026-09-27

Part

# Keypad, 4x4

Sixteen keys on eight pins. Scan a row at a time, and mind the ghosting.

or see every part

- 8 pins

Drawn live by the editor's own code, at the size you see it.

Reference

## Every one of its 8 pins

Pin

What it does

R1

R2

R3

R4

C1

C2

C3

C4

This part

## What it does

The 4x4 membrane keypad has sixteen keys, eight pins and no chip inside. Under each key a carbon pad shorts one row trace to one column trace, and that is all it does, which is why a sketch has to scan it: drive one row low, read the four columns with their pull-ups on, and a column that reads low is a key held in that row. Mokxi models the keys as real contacts that pass current both ways, so it keeps the faults of the real part too. Three keys held in a rectangle make the fourth corner read as pressed, the ghosting that membrane keypads without diodes have, and driving a row high while another key shorts it low puts two outputs against each other as it would on a desk. It does not model contact bounce; that lesson belongs to the pushbutton. Click a key in the editor to hold it down.

How to use it

## How to use a 4x4 keypad with an Arduino

Eight wires: the four rows and the four columns to eight digital pins. Scan it: set the columns as inputs with pull-ups, drive one row LOW at a time, and read the columns; a column that reads LOW is a key held in that row. Do it every few milliseconds and report a key once, when it first goes down.

Drive rows low, never high, while scanning. With two keys held in one column, a high row would be shorted straight to a low one.

Part pin

Board pin

R1, R2, R3, R4

Pins 9, 8, 7, 6

C1, C2, C3, C4

Pins 5, 4, 3, 2

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

How it is modeled

## What is true about the Keypad, 4x4, here

### What is modeled

A closed key is a real low-resistance contact passing whatever is on either side in
either direction. The model does nothing to stop a row driven high while another
key shorts it to a driven low, because a real keypad does nothing to stop that
either. Ghosting is modeled too: three keys held in a rectangle make the fourth
corner read as pressed, because current has a way around through the three that are
closed, exactly what a real matrix keypad with no diodes does, and the reason a
keypad sketch normally reads one key at a time.

### Not modeled

No diodes on the keys. Some keypads add one per key to prevent ghosting, but the
cheap membrane kind does not, and neither does this part.

No contact bounce. A real membrane key's carbon pad chatters for a millisecond or
two and a scanning sketch has to settle for it; here a key closes exactly once. That is
a deliberate omission, not an oversight (the bounce lesson belongs to
the pushbutton), but it means a keypad sketch that would need
debouncing on the bench runs clean here. There is no contact resistance drift, no row
or column capacitance and no settle time after a row is driven, so a scan can be as
fast as the firmware likes.

From 4x4 membrane keypad, in full.

Projects

## See the Keypad, 4x4 in a project

Shown here on: Arduino Uno R3

Learn

## Where it turns up in a lesson

### In a learn article

- Arduino 4x4 Keypad Code Lock with a Relay

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio, no real internet), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

STM32F411 Black Pill

The Black Pill on our own Cortex-M4 core. Pick a program and press Run.

BBC micro:bit V2

The nRF52833 board with its 5x5 LED matrix, buttons A and B and a speaker. Wire the rings to a breadboard.

See every part

## Wire up the Keypad, 4x4

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building Open the editor
