--- id: keyboard version: "0.13.5" license: MIT license_treatment: permissive maintenance: active --- # keyboard — Hook and simulate keyboard events on Windows and Linux License: permissive · Maintenance: active · Downloads: 947.4K/mo ## 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 above — verify before relying. Hook global keyboard events, register hotkeys, and simulate key presses across Windows, Linux, and macOS from Python. 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 pip install keyboard uv add keyboard poetry add keyboard ## Installing keyboard 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). 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') Linux requires root/sudo access to read raw device files. Windows and macOS do not require elevated privileges. 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: unspecified - Install friction: low - Maintenance: active - Downloads: 947.4K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags keyboard event hook, global hotkey registration, simulate key presses, keyboard input capture, keyboard automation, key event listener, hotkey binding, input-automation, system-integration [View on SkillFed](https://skillfed.io/packages/keyboard) · [View on PyPI](https://pypi.org/project/keyboard/)