keyboard
Hook and simulate keyboard events on Windows and Linux
Decision gist · record as of 2026-08-14
Yes, if you need global keyboard control on Windows or Linux. The package is actively maintained, has no known vulnerabilities, and low install friction. On macOS, experimental support means you should test thoroughly before relying on it. Note that Linux requires root/sudo and Windows has the most complete feature set; key suppression is Windows-only.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Linux requires root/sudo access to read raw device files.
- Windows and macOS do not require elevated privileges.
- Low friction install with a single pure-Python runtime dependency (pyobjc).
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; you must include the license notice in distributions.
last release 2020-03-23 (2335 days) · last repo commit 2026-07-10 · 3,961 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 947,380 downloads/mo, #4,664 on PyPI
Alternatives
Verify before relying
pip install keyboard
import keyboard
keyboard.add_hotkey('ctrl+shift+a', lambda: keyboard.write('hello'))
keyboard.wait('esc')- Whether pyobjc is automatically installed on non-macOS systems or only when needed
- Current state of experimental macOS support and any known stability issues
- Whether key suppression/blocking has been implemented on Linux since the last release
What it is and what it does
keyboard is a Python library that gives you low-level control over keyboard input and output on Windows, Linux, and macOS. It lets you hook global keyboard events (capturing key presses regardless of which window has focus), register complex hotkey combinations, simulate key presses, and record/replay keyboard sequences. The library runs event capture in a separate thread so it doesn't block your main program.
The package is pure Python with no C compilation required, making it trivial to install and deploy. It depends on pyobjc for macOS support. Known limitations include that key suppression only works on Windows, Linux requires root access to read raw device files, and some applications can swallow key events before keyboard sees them.
Use it for
- Build system-wide hotkey handlers that trigger functions regardless of active window
- Automate repetitive typing tasks by simulating key sequences and text input
- Record keyboard activity for playback at different speeds or for testing
- Create keyboard shortcuts for accessibility or custom application workflows
- Implement text abbreviation expansion (e.g., replace '@@' with an email address)
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need global keyboard control on Windows or Linux.
The package is actively maintained, has no known vulnerabilities, and low install friction. On macOS, experimental support means you should test thoroughly before relying on it. Note that Linux requires root/sudo and Windows has the most complete feature set; key suppression is Windows-only.
Install
keyboard on PyPI
Before you install
Low friction install with a single pure-Python runtime dependency (pyobjc). Actively maintained as of July 2026 with 3961 repository stars and steady popularity (top 5000 PyPI packages by downloads).
Linux requires root/sudo access to read raw device files. Windows and macOS do not require elevated privileges.
License in practice
MIT license permits commercial and private use with minimal restrictions; you must include the license notice in distributions.
Quickstart
pip install keyboard
import keyboard
keyboard.add_hotkey('ctrl+shift+a', lambda: keyboard.write('hello'))
keyboard.wait('esc')
Verify before relying
- Whether pyobjc is automatically installed on non-macOS systems or only when needed
- Current state of experimental macOS support and any known stability issues
- Whether key suppression/blocking has been implemented on Linux since the last release
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepyobjc |
| Maintenance | Actively maintained 2,335 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 947,380 / month, #4,664 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: UnixProgramming Language :: Python :: 2Programming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python ModulesTopic :: Utilities |
Evidence: keyboard-0.13.5-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “keyboard event hook”
- keyboardHook global keyboard events, register hotkeys, and simulate key…
- ipyeventsipyevents provides a Jupyter widget that captures mouse and keyboard…
- evdevProvides Python bindings to Linux's evdev and uinput input event…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also sshkeyboard · inputs · PyAutoGUI · pynput · pynput-robocorp-fork · PyDirectInput · ipyevents · pywinauto · python-yakh · readchar