gpio-pedal
Turn any Raspberry Pi GPIO pin into a keyboard shortcut.
Wire a foot pedal, footswitch, or momentary button to a GPIO pin and gpio-pedal will simulate whatever key press you configure — space bar, Ctrl+C, a media key, anything. Works great for hands-free control, live performance, transcription, accessibility setups, or any situation where your hands are busy.
Features
- Map any number of GPIO pins to individual keys or key combinations (
ctrl+c,shift+f1, etc.) - Configurable debounce time to eliminate phantom presses
- Load config from a JSON or YAML file, or pass a plain Python dict
- CLI command (
gpio-pedal config.json) for running without writing any code - Clean shutdown on Ctrl+C with automatic GPIO cleanup
Requirements
- Raspberry Pi (any model with GPIO)
- Python 3.9 or higher
- A normally-open momentary switch wired between a GPIO pin and GND
Installation
pip install gpio-pedal
For YAML config file support:
pip install gpio-pedal[yaml]
Hardware Setup
Wire your switch between the GPIO pin and GND. gpio-pedal enables the internal pull-up resistor automatically, so no external resistor is needed.
GPIO pin ──── [switch] ──── GND
For example, to use GPIO 17:
Pin 11 (GPIO 17) ──── [foot pedal] ──── Pin 9 (GND)
Use BCM pin numbering (the number after "GPIO", not the physical pin number).
Quick Start
from gpio_pedal import PedalController
config = {
17: "space", # GPIO 17 → Spacebar
22: "ctrl+c", # GPIO 22 → Ctrl+C
27: "m", # GPIO 27 → M key
}
pedal = PedalController(config)
pedal.run()
CLI Usage
Create a JSON config file:
{
"17": "space",
"22": "ctrl+c",
"27": "m"
}
Then run:
gpio-pedal config.json
Options:
gpio-pedal config.json --bouncetime 200 # faster debounce (ms)
gpio-pedal config.json --verbose # debug logging
gpio-pedal --version
gpio-pedal --help
Config File Format
| Format | Extension | Install |
|---|---|---|
| JSON | .json |
built-in |
| YAML | .yaml / .yml |
pip install gpio-pedal[yaml] |
JSON example:
{
"17": "space",
"22": "ctrl+z",
"27": "shift+f5"
}
YAML example:
17: space
22: ctrl+z
27: shift+f5
Keys can be single characters (a, 1, !) or any key name from
pynput's Key enum,
such as space, enter, tab, ctrl, shift, alt, f1–f20, etc.
Combine them with + for shortcuts.
Python API
from gpio_pedal import PedalController, load_config
from gpio_pedal.utils import list_special_keys, describe_config
# Load from a file
config = load_config("config.json")
# Or define inline
config = {17: "space", 22: "ctrl+c"}
# See all supported special key names
print(list_special_keys())
# Preview your config before running
print(describe_config(config))
# Start listening (blocks until Ctrl+C)
controller = PedalController(config, bouncetime=300)
controller.run()
Development
git clone https://github.com/whitneyjsmith/gpio-pedal.git
cd gpio-pedal
pip install -e ".[dev]"
pytest
License
Distributed under the MIT License. See LICENSE for details.
Metadata
Release files for gpio-pedal 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gpio_pedal-0.1.1.tar.gz | 13.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gpio_pedal-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.8 kB
Release files / gpio_pedal-0.1.1.tar.gz
| Download URL | gpio_pedal-0.1.1.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66821c8867632437ee79052e86abf73297b6fce640e18770834433992771e889
|
|
BLAKE2b-256 checksum How to use checksums |
0ba1c7babe2c297f400f8a08bdb6b567610a4bee120a9d7cce810e4c4bcfc122
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / gpio_pedal-0.1.1-py3-none-any.whl
| Download URL | gpio_pedal-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f02a0909ca8da422d5257d7c798db563149c6eb38759d6781d2b97f589341d58
|
|
BLAKE2b-256 checksum How to use checksums |
901f47b5dbd19ce4b2d603fce73de6393d13c2d57765048b0813f71b51145b9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|