https://github.com/bkbilly/xlib_hotkeys
Register Keyboard Hotkeys to a callback function
https://github.com/bkbilly/xlib_hotkeys
Last synced: 5 months ago
JSON representation
Register Keyboard Hotkeys to a callback function
- Host: GitHub
- URL: https://github.com/bkbilly/xlib_hotkeys
- Owner: bkbilly
- License: mit
- Created: 2024-03-25T15:26:56.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-25T15:41:45.000Z (over 2 years ago)
- Last Synced: 2025-10-26T16:57:07.361Z (8 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# xlib-hotkeys
[](https://pypi.python.org/pypi/xlib-hotkeys)


Python library for Linux to register keyboard combinations to a callback function.
## Requirements
* Python 3.7 or later
## Installation
Install using:
```
pip install xlib-hotkeys
```
## Usage
You can use this module from the command line
```bash
xlib-hotkeys -h
xlib-hotkeys -d :0 -k ctrl+return shift+f2
```
```python
from xlib_hotkeys import HotKeysManager
def KeyDown(key, keyspressed):
print(f"Keys Pressed: {keyspressed}")
def Hotkey1():
print(f" Hotkey1 detected")
def Hotkey2():
print(f" Hotkey2 detected")
hk = HotKeysManager(display_str=":0")
hk.KeyDown = KeyDown
hk.hotkeys["ctrl+return"] = Hotkey1()
hk.hotkeys["shift+f2"] = Hotkey2()
hk.start()
time.sleep(50)
hk.stop()
```