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

Uploaded Source

Built Distribution

reflex_global_hotkey-1.1.1-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for reflex_global_hotkey-1.1.1.tar.gz
Algorithm Hash digest
SHA256 11e3bdc0795ce3e55a69119934ea07773eb32ce5e7c5c34c53fa2c7c1e68a58d
MD5 84b20e4d92f026f1f797ffe77696711c
BLAKE2b-256 fb20ee0f3ddd67c3465a82b98f581a1809d7b04b0506cb403960e707b9f3dce2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for reflex_global_hotkey-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fcf8a4954e9e1335b0636cdd9d97c88e8f99b61deaaedeadd2ded102bf1c85a7
MD5 05d0b4a0e238ec1375b7a83c9bc10b69
BLAKE2b-256 e5b3c33acb652c69dde5ec17917d9b0b8ec046d9d08d2e246a9eb197acab3c30

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