Skip to main content

Global Hotkey Watcher for Reflex

Project description

Reflex Global Hotkey Watcher

Listens to hotkeys in the global scope and calls event handler as necessary.

from reflex_global_hotkey import global_hotkey_watcher

class State(rx.State):
    last_key_pressed: str = ""

    def on_key(self, keyname: str):
        self.last_key_pressed = keyname

def index():
    return rx.fragment(
        State.last_key_pressed,
        global_hotkey_watcher(
            on_key_down=State.on_key
        )
    )

You can special case on the event key:

global_hotkey_watcher(
    on_key_down=lambda key_name: rx.cond(
        rx.Var.create(
            ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]
        ).contains(key_name),
        State.on_key(key_name),
        rx.console_log("Invalid key!"),
    )
)

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

reflex_global_hotkey-1.1.0.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

reflex_global_hotkey-1.1.0-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

Details for the file reflex_global_hotkey-1.1.0.tar.gz.

File metadata

  • Download URL: reflex_global_hotkey-1.1.0.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.6 Linux/6.10.9-amd64

File hashes

Hashes for reflex_global_hotkey-1.1.0.tar.gz
Algorithm Hash digest
SHA256 0c0980c253a1b2a7a15698c3b416afed2ac99c59345c445e3f3cc1e284a0bafe
MD5 d98c8290afe5d80be5d5881349a0659d
BLAKE2b-256 cd1d62b62660f06e9665e82d6826c27163725cd5d8f42947edda96fa1c3201d5

See more details on using hashes here.

File details

Details for the file reflex_global_hotkey-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for reflex_global_hotkey-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b5fdf8e575b54c3eae9ebfbd60f3e40dfecd09fd89101c76131a9d4e3026063
MD5 5938985c2fdfad1e82458ad83f922a5c
BLAKE2b-256 8d0edcab0e32d4895e9fb4cec68511a428f71efc65d21a6a95b8c79a65099e83

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