keyboard: Python Library for Global Keyboard Event Control

This repository profile is provided by osrepos.com, an open source repository discovery platform.

keyboard: Python Library for Global Keyboard Event Control

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

Analyzed by OSRepos on January 21, 2026

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.

OpenMontage: The First Open-Source, Agentic Video Production System

OpenMontage: The First Open-Source, Agentic Video Production System

June 29, 2026

OpenMontage is the world's first open-source, agentic video production system, designed to transform your AI coding assistant into a full video production studio. It features 12 pipelines, 52 tools, and over 500 agent skills, enabling end-to-end video creation from a simple prompt. This powerful tool handles research, scripting, asset generation, editing, and final composition, including the unique ability to produce real video from stock footage.

agentic-aivideo-productionopen-source
MarkLLM: An Open-Source Toolkit for LLM Watermarking

MarkLLM: An Open-Source Toolkit for LLM Watermarking

June 23, 2026

MarkLLM is an open-source toolkit designed to simplify the research and application of watermarking technologies for large language models (LLMs). It offers a unified framework for implementing various watermarking algorithms, alongside robust visualization and comprehensive evaluation tools. This toolkit helps researchers and the broader community understand and assess the authenticity and origin of machine-generated text.

large-language-modelsllmsafety
Agent-Reach: Empower Your AI Agents with Internet Access, Zero API Fees

Agent-Reach: Empower Your AI Agents with Internet Access, Zero API Fees

June 21, 2026

Agent-Reach is a powerful GitHub repository that equips AI agents with the ability to access and search the entire internet, including platforms like Twitter, Reddit, YouTube, and Bilibili. It provides a streamlined CLI experience, eliminating the need for complex API configurations and associated fees. This project ensures your AI agent can "see" and interact with web content effortlessly.

ai-agentagent-infrastructureai-search
REAL Video Enhancer: AI-Powered Video Interpolation, Upscaling, and Denoising

REAL Video Enhancer: AI-Powered Video Interpolation, Upscaling, and Denoising

June 19, 2026

REAL Video Enhancer is a powerful open-source application designed to enhance video quality across Linux, Windows, and macOS. It leverages AI models for advanced video processing tasks such as frame interpolation, upscaling, decompression, and denoising. This tool provides a modern alternative to older software, making high-quality video enhancement accessible to a wider audience.

video-enhancementaiupscaling

Source repository

Open the original repository on GitHub.

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️