keyboard: Python Library for Global Keyboard Event Control
This repository profile is provided by osrepos.com, an open source repository discovery platform.
Summary
The `keyboard` library is a powerful Python tool designed to hook and simulate global keyboard events across Windows and Linux, with experimental macOS support. It offers comprehensive control over keyboard interactions, allowing users to listen for events, register complex hotkeys, and simulate key presses. Despite being currently unmaintained, it remains a functional solution for many use cases requiring direct keyboard manipulation.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
The keyboard library by boppreh is a versatile Python tool that provides full control over global keyboard events. It allows developers to hook into keyboard events, register custom hotkeys, and simulate key presses on Windows, Linux, and experimentally on macOS. While the project is currently unmaintained, it offers a robust set of features for many applications requiring direct interaction with the keyboard.
Installation
Getting started with keyboard is straightforward. You can install it via pip or by cloning the repository directly.
To install using pip:
pip install keyboard
Alternatively, you can clone the GitHub repository, as no installation is required; the source files are sufficient:
git clone https://github.com/boppreh/keyboard
Examples
The keyboard library offers a high-level API for various keyboard interactions. Here are a few examples to illustrate its capabilities:
Simulating Key Presses and Typing:
import keyboard
# Press and release a hotkey combination
keyboard.press_and_release('shift+s, space')
# Type a string of text
keyboard.write('The quick brown fox jumps over the lazy dog.')
Registering Hotkeys:
# Register a hotkey to print a message
keyboard.add_hotkey('ctrl+shift+a', print, args=('triggered', 'hotkey'))
# Register a multi-step hotkey to type text
keyboard.add_hotkey('page up, page down', lambda: keyboard.write('foobar'))
Recording and Playing Events:
# Blocks until 'esc' is pressed, recording all events
recorded = keyboard.record(until='esc')
# Replay the recorded events at three times the speed
keyboard.play(recorded, speed_factor=3)
Creating Abbreviations:
# Type '@@' then press space to replace with an email address
keyboard.add_abbreviation('@@', 'my.long.email@example.com')
Waiting for a Key Press:
# Blocks the program until 'esc' is pressed
keyboard.wait('esc')
Why Use It
The keyboard library stands out for several reasons:
- Global Event Hook: Captures key events regardless of the active window's focus.
- Cross-Platform Support: Works on Windows, Linux (requires sudo), and offers experimental macOS support.
- Pure Python & Zero Dependencies: Easy to install and deploy without complex compilation or external requirements.
- Internationalization: Maps keys according to your actual keyboard layout, supporting international characters like
Ctrl+ç. - Complex Hotkey Support: Allows for intricate hotkey combinations and sequences (e.g.,
ctrl+shift+m, ctrl+space). - High-Level API: Includes convenient functions for recording/playing events and adding abbreviations.
- Asynchronous Event Handling: Events are captured in a separate thread, preventing the main program from blocking.
Links
You can find more information, contribute, or report issues by visiting the official repository and PyPI page:
Related repositories
Similar repositories that may be relevant next.

nanobot: An Ultra-Lightweight, Self-Hosted Personal AI Agent Framework
August 9, 2026
nanobot is an ultra-lightweight, open-source, self-hosted personal AI agent framework built in Python. It offers a WebUI, tools, memory, multi-agent workflows, and automation capabilities, making it a versatile solution for personal AI tasks. Users can deploy it across various platforms, including chat apps, for seamless integration.

ReMe: An Advanced Memory Management Kit for AI Agents
August 7, 2026
ReMe is an innovative, local-first memory layer designed for AI agents, transforming conversations and resources into file-based long-term memory. It continuously indexes, links, and consolidates this information, enabling advanced recall and supporting the development of self-evolving agents. This kit helps agents remember and refine their experiences effectively.

code-review-graph: AI-Powered Code Intelligence for Smarter Reviews
August 6, 2026
code-review-graph is a local-first code intelligence graph that optimizes AI coding tools by building a persistent map of your codebase. It significantly reduces context for AI reviews and large-repo workflows, ensuring AI assistants read only the most relevant code. This leads to more efficient and cost-effective code analysis.

Nikola: A Powerful Static Website and Blog Generator
August 6, 2026
Nikola is an open-source static website and blog generator written in Python. It transforms content into a deployable website, offering a secure and resource-efficient alternative to dynamic sites. With features like theming, fast builds, and multilingual support, Nikola is a versatile tool for web development.
Source repository
Open the original repository on GitHub.
16 counted GitHub visits