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_hoykey_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_hoykey_watcher(
            on_key_down=State.on_key
        )
    )

You can special case on the event key:

global_hoykey_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.0.0.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: reflex_global_hotkey-1.0.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.0.0.tar.gz
Algorithm Hash digest
SHA256 c77713ba1cf85d071761e5e8e676d9c64bf9cef823de1bf8a7a81d2fe1d9d879
MD5 150d6730b3c27f69ac78987391b907f7
BLAKE2b-256 e32645248e12d179d4f4733f402b95fca786dd6358c9e0170eb573dd3aa4c366

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for reflex_global_hotkey-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7acaa1bdd75a1387fdab52a05d88b6c174eac0251bd3b4568e7d416790d3bdf
MD5 4099b6ba803ed84bed66d0028abdaa57
BLAKE2b-256 a866c1bd1283bf4b987d725f9fc164454ee822567f2e78c8a015b54aa34564ba

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