Install & Compatibility
Where this runs
tested against v1.8.1.20260603 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
keyboard
✓ from pynput-stubs import keyboard
✗ from pynput import keyboard
mouse
✓ from pynput-stubs import mouse
✗ from pynput import mouse
Quickstart showing a basic keyboard listener with type stubs active.
from pynput import keyboard
def on_press(key):
try:
print(f'Alphanumeric key pressed: {key.char}')
except AttributeError:
print(f'Special key pressed: {key}')
with keyboard.Listener(on_press=on_press) as listener:
listener.join()
Upgrade
Version history
1.8.1.20260603latest on PyPI · released Jun 3, 2026
Audit
Dependencies
pynputrequiredStubs only type-check code using pynput; pynput must be installed at runtime.