(right).
Separate connections A mechanically-switched 16-key keypad can be connected to a host through 16 separate connecting
leads, plus a
ground lead (Figure 1, left). Pressing a key will
short to ground, which is detected by the host. This design allows any number or combination of keys can be pressed simultaneously.
Parallel-in serial-out shift registers may be used to
save I/O pins.
X/Y multiplexing These 16 + 1 leads can be reduced to just 8 by using x/y multiplexing (Figure 1, center). A 16-key keypad uses a 4 × 4 array of 4 I/O lines as outputs and 4 as inputs. A circuit is completed between an output and an input when a key is pressed. Each individual keypress creates a unique signal for the host. If required, and if the processor allows, two keys can be pressed at the same time without ambiguity. Adding
diodes in series with each key prevents
key ghosting, allowing multiple simultaneous presses.
Charlieplexing Eight leads can detect many more keys if
tri-state multiplexing (Figure 1, right) is used instead, which enables (
n-1) × (
n/2) keys to be detected with just
n I/O lines. Eight I/O can detect 28 individual keys without ambiguity. Issues can occur with some combinations if two keys are pressed simultaneously. If diodes are used, then the number of unique keys detectable is doubled. ==See also==