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.
OpenSandbox: A Secure and Extensible Sandbox Runtime for AI Agents
August 12, 2026
OpenSandbox is a powerful, general-purpose sandbox platform designed for AI applications. It provides secure, fast, and extensible runtime environments, supporting multi-language SDKs and Docker/Kubernetes deployments. This project is ideal for developing and evaluating AI agents in isolated, controlled settings.

FastMCP: The Pythonic Framework for Model Context Protocol Applications
August 11, 2026
FastMCP is a robust, Pythonic framework developed by PrefectHQ, designed to simplify the creation of Model Context Protocol (MCP) servers and clients. It provides a comprehensive application framework for connecting Large Language Models (LLMs) to tools and data, handling complexities like schema generation, validation, and protocol lifecycle. As the standard framework for MCP, FastMCP empowers developers to build powerful LLM-integrated applications efficiently.

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.
Source repository
Open the original repository on GitHub.
16 counted GitHub visits