boppreh

keyboard: Capture and Simulate Keyboard Events in Python

A Python library for listening to and generating global keyboard events, registering hotkeys, and recording or replaying input. Useful for desktop automation and keyboard-driven tools, with platform permissions and support limitations to consider.

View on GitHub Compare
Stars
4k
Forks
450
Stars, last 30 days
+0

Our take

Health score

32/100

How it is scored
Activity
19
Community
43
Issues
46
Pull requests
20

+0 stars in the last 30 days

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

3,971

Forks

451

Change since Nov 17, 2026: 0 stars·0 forks

Overview

keyboard is a Python library for capturing and sending keyboard events beyond the currently focused application. It gives scripts a way to respond to key presses, define hotkeys, type text, and record or replay input without compiling native modules or installing dependencies.

It is suited to Python developers building keyboard-driven utilities or automations that need system-wide input. The project README describes it as currently unmaintained, so it may be a practical fit for existing workflows or limited requirements, but less suitable when active maintenance or broad platform support is essential.

Key Features

  • Capture global key press and release events through callbacks or blocking reads.
  • Register single-key and multi-step hotkeys, with optional callbacks and suppression.
  • Send key events, type text, and check whether keys are pressed.
  • Record keyboard events and replay them while preserving relative timing.
  • Add typed-word listeners and text abbreviations.
  • Use a pure Python implementation with no package dependencies, according to the README.

Use Cases

  • Build a desktop utility that runs an action when a user presses a global hotkey.
  • Automate repetitive keyboard input in applications where sending key events is appropriate.
  • Record and replay keyboard workflows for a personal script or test setup.
  • Create text expansion shortcuts for frequently typed phrases.

Getting Started

Install the package with:

pip install keyboard

See the README for usage examples and API details.

Considerations

  • The README says the project is currently unmaintained, and notes that features may be limited.
  • Windows and Linux are supported; Linux access to raw input device files requires root privileges. OS X support is described as experimental.
  • Key suppression and blocking are available only on Windows. Linux media-key reporting can be incomplete, and some applications may prevent hooks from seeing events.
  • Global keyboard capture and simulated input require care. The README cautions against using the library for keyloggers or online gaming bots.

Found this useful?

Share it with someone who would like keyboard.