skillfed

keyboard

Hook and simulate keyboard events on Windows and Linux

keyboard v0.13.5 947.4K downloads/30d#4,664 on PyPI3,961
Permissive license MIT Active released

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

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

keyboard on PyPI

pip

pip install keyboard

uv

uv add keyboard

poetry

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 not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — pyobjc
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)

Evidence: keyboard-0.13.5-py3-none-any.whl

Keywords: keyboard, hook, simulate, hotkey

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

Tags

keyboard event hookglobal hotkey registrationsimulate key presseskeyboard input capturekeyboard automationkey event listenerhotkey binding
input-automationsystem-integration

More Python Modules packages