Skip to main content

Interrupt-based matrix keypad library for Raspberry Pi

Project description


An interrupt-based Python 2/3 library for reading matrix keypad key presses using Raspberry Pi GPIO pins.

pip install pad4pi

Tested on a Raspberry Pi B+ using a 4x3 matrix keypad but should work with 4x4 and other sizes.


from pad4pi import rpi_gpio


ROW_PINS = [4,14,15,17] # BCM numbering
COL_PINS = [18,27,22] # BCM numbering

factory = rpi_gpio.KeypadFactory()

# Try factory.create_4_by_3_keypad
# and factory.create_4_by_4_keypad for reasonable defaults
keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS)

def printKey(key):

# printKey will be called each time a keypad button is pressed

When your program exits, call keypad.cleanup() to ensure the Raspberry Pi’s GPIO pins are reset.


Licensed under GNU Lesser General Public License Version 3 (LGPL v3).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pad4pi, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size pad4pi-1.0.0.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page