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.

Vicoa: Agentic IDE for Orchestrating Coding Agents Across Devices

Vicoa: Agentic IDE for Orchestrating Coding Agents Across Devices

September 29, 2026

Vicoa is an open-source, self-hostable agentic IDE designed to orchestrate a team of coding agents. It enables developers to run and steer multiple AI agents from various devices, including desktop, mobile, and remote servers, providing a unified command center for development workflows.

ai-agentsidedeveloper-tools
Open ACE: Self-Hosted AI Coding Agent Workspace and Governance Platform

Open ACE: Self-Hosted AI Coding Agent Workspace and Governance Platform

September 28, 2026

Open ACE is an open-source, self-hosted platform designed for managing AI coding agents within enterprise environments. It provides a unified workspace for various AI tools, enabling remote execution and robust governance features for API keys, costs, and compliance. This platform is ideal for organizations integrating AI coding agents into their development workflows, especially those requiring private deployment and centralized control.

ai-governanceai-workspaceenterprise-ai
Spec Kitty: Spec-Driven Development for AI Coding Agents and Software Factories

Spec Kitty: Spec-Driven Development for AI Coding Agents and Software Factories

September 27, 2026

Spec Kitty is an open-source CLI that enables spec-driven development for AI coding agents and multi-agent workflows. It transforms product intent into a structured, repo-native AI coding workflow, providing isolated git worktrees and a clear lifecycle for development tasks. This tool helps teams build governed software factories, ensuring visibility and traceability in AI-assisted software development.

agentic-codingai-agentsai-coding-workflow
Graphon: A Python Graph Execution Engine for Agentic AI Workflows

Graphon: A Python Graph Execution Engine for Agentic AI Workflows

September 26, 2026

Graphon is an innovative Python-based graph execution engine designed for building agentic AI workflows. It provides a robust framework for orchestrating complex AI tasks, featuring event-driven execution, graph validation, and shared runtime state. This evolving repository already includes a functional engine, built-in nodes, and end-to-end examples for developers.

agentaidify

Source repository

Open the original repository on GitHub.

18 counted GitHub visits

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 ❤️