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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file xlib_hotkeys-2024.3.0.tar.gz.

File metadata

  • Download URL: xlib_hotkeys-2024.3.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for xlib_hotkeys-2024.3.0.tar.gz
Algorithm Hash digest
SHA256 2911a8678e4e814e5438c6489930c8ae04d714fcda00dd0dfc8bc77a89d6d945
MD5 374796fd8af5ff8ee74c4c95ca54f8e6
BLAKE2b-256 80cb13aaffbd3e9dc729dd41ab6baa2432ff7874ea789fb4b218474e2af0a711

See more details on using hashes here.

File details

Details for the file xlib_hotkeys-2024.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xlib_hotkeys-2024.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea3afbd683ebf794aa8411a917c1688e0c04fae80f9110a1feece7ed0d5c025c
MD5 07a81736b4c6b299d4051776ac0d1304
BLAKE2b-256 5da21e88b5862b2bd93e7316417250e505c767fe18d3491f8a3ceb5022710c90

See more details on using hashes here.

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