{"name":"keyboard: Python Library for Global Keyboard Event Control","description":"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.","github":"https://github.com/boppreh/keyboard","url":"https://osrepos.com/repo/boppreh-keyboard","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/boppreh-keyboard","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/boppreh-keyboard.md","json":"https://osrepos.com/repo/boppreh-keyboard.json","topics":["python","keyboard-events","hotkey","keyboard-hooks","automation","system-utility","callback","scancode"],"keywords":["python","keyboard-events","hotkey","keyboard-hooks","automation","system-utility","callback","scancode"],"stars":null,"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.","content":"## Introduction\n\nThe `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.\n\n## Installation\n\nGetting started with `keyboard` is straightforward. You can install it via pip or by cloning the repository directly.\n\nTo install using pip:\nbash\npip install keyboard\n\n\nAlternatively, you can clone the GitHub repository, as no installation is required; the source files are sufficient:\nbash\ngit clone https://github.com/boppreh/keyboard\n\n\n## Examples\n\nThe `keyboard` library offers a high-level API for various keyboard interactions. Here are a few examples to illustrate its capabilities:\n\n### Simulating Key Presses and Typing:\npython\nimport keyboard\n\n# Press and release a hotkey combination\nkeyboard.press_and_release('shift+s, space')\n\n# Type a string of text\nkeyboard.write('The quick brown fox jumps over the lazy dog.')\n\n\n### Registering Hotkeys:\npython\n# Register a hotkey to print a message\nkeyboard.add_hotkey('ctrl+shift+a', print, args=('triggered', 'hotkey'))\n\n# Register a multi-step hotkey to type text\nkeyboard.add_hotkey('page up, page down', lambda: keyboard.write('foobar'))\n\n\n### Recording and Playing Events:\npython\n# Blocks until 'esc' is pressed, recording all events\nrecorded = keyboard.record(until='esc')\n# Replay the recorded events at three times the speed\nkeyboard.play(recorded, speed_factor=3)\n\n\n### Creating Abbreviations:\npython\n# Type '@@' then press space to replace with an email address\nkeyboard.add_abbreviation('@@', 'my.long.email@example.com')\n\n\n### Waiting for a Key Press:\npython\n# Blocks the program until 'esc' is pressed\nkeyboard.wait('esc')\n\n\n## Why Use It\n\nThe `keyboard` library stands out for several reasons:\n\n*   **Global Event Hook**: Captures key events regardless of the active window's focus.\n*   **Cross-Platform Support**: Works on Windows, Linux (requires sudo), and offers experimental macOS support.\n*   **Pure Python & Zero Dependencies**: Easy to install and deploy without complex compilation or external requirements.\n*   **Internationalization**: Maps keys according to your actual keyboard layout, supporting international characters like `Ctrl+ç`.\n*   **Complex Hotkey Support**: Allows for intricate hotkey combinations and sequences (e.g., `ctrl+shift+m, ctrl+space`).\n*   **High-Level API**: Includes convenient functions for recording/playing events and adding abbreviations.\n*   **Asynchronous Event Handling**: Events are captured in a separate thread, preventing the main program from blocking.\n\n## Links\n\nYou can find more information, contribute, or report issues by visiting the official repository and PyPI page:\n\n*   [GitHub Repository](https://github.com/boppreh/keyboard)\n*   [PyPI Package](https://pypi.python.org/pypi/keyboard/)","metrics":{"detailViews":4,"githubClicks":6},"dates":{"published":null,"modified":"2026-01-21T12:01:03.000Z"}}