Skip to main content

Register Keyboard Hotkeys to a callback function

Project description

xlib-hotkeys

pypi python version license

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

xlib-hotkeys -h
xlib-hotkeys -d :0 -k ctrl+return shift+f2
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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xlib_hotkeys-2024.3.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

xlib_hotkeys-2024.3.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page