keypad module, available in CircuitPython 7.0.0 and later, scans a set of keys or buttons in the background, while your program is doing other things, and gives you key-pressed and key-released events. The module provides three different kinds of scanners, which cover common ways of connecting keys to pins.
Keys: Each key is connected to a separate pin.
KeyMatrix: The keys are wired in a row-column matrix, with or without diodes. This is how most typing keyboards, music keyboards, and telephone-style keypads are wired.
ShiftRegisterKeys: The keys are connected to an external parallel-in serial-out shift register. The keys are read by clocking data from the shift register into a single input pin.
Each time a key is pressed or released, a scanner will record an
Event in an
EventQueue. Each event gives the key number, and says whether the key has been pressed or released. Your program can read the events sequentially.
The background scanning does debouncing as well, so you don't have to worry about handling that yourself.
This Guide will explain how each of the scanners works, and provide some simple examples.