reflex-global-hotkey


Namereflex-global-hotkey JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttps://github.com/adhami3310/reflex-global-hotkey
SummaryGlobal Hotkey Watcher for Reflex
upload_time2024-11-13 03:55:58
maintainerNone
docs_urlNone
authorKhaleel Al-Adhami
requires_python<4.0,>=3.10
licenseMIT
keywords reflex reflex-custom-components
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Reflex Global Hotkey Watcher

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

```python
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:

```python
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!"),
    )
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/adhami3310/reflex-global-hotkey",
    "name": "reflex-global-hotkey",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "reflex, reflex-custom-components",
    "author": "Khaleel Al-Adhami",
    "author_email": "khaleel.aladhami@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fb/20/ee0f3ddd67c3465a82b98f581a1809d7b04b0506cb403960e707b9f3dce2/reflex_global_hotkey-1.1.1.tar.gz",
    "platform": null,
    "description": "# Reflex Global Hotkey Watcher\n\nListens to hotkeys in the global scope and calls event handler as necessary.\n\n```python\nfrom reflex_global_hotkey import global_hotkey_watcher\n\nclass State(rx.State):\n    last_key_pressed: str = \"\"\n\n    def on_key(self, keyname: str):\n        self.last_key_pressed = keyname\n\ndef index():\n    return rx.fragment(\n        State.last_key_pressed,\n        global_hotkey_watcher(\n            on_key_down=State.on_key\n        )\n    )\n```\n\nYou can special case on the event key:\n\n```python\nglobal_hotkey_watcher(\n    on_key_down=lambda key_name: rx.cond(\n        rx.Var.create(\n            [\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\"]\n        ).contains(key_name),\n        State.on_key(key_name),\n        rx.console_log(\"Invalid key!\"),\n    )\n)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Global Hotkey Watcher for Reflex",
    "version": "1.1.1",
    "project_urls": {
        "Homepage": "https://github.com/adhami3310/reflex-global-hotkey",
        "Repository": "https://github.com/adhami3310/reflex-global-hotkey"
    },
    "split_keywords": [
        "reflex",
        " reflex-custom-components"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5b3c33acb652c69dde5ec17917d9b0b8ec046d9d08d2e246a9eb197acab3c30",
                "md5": "05d0b4a0e238ec1375b7a83c9bc10b69",
                "sha256": "fcf8a4954e9e1335b0636cdd9d97c88e8f99b61deaaedeadd2ded102bf1c85a7"
            },
            "downloads": -1,
            "filename": "reflex_global_hotkey-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "05d0b4a0e238ec1375b7a83c9bc10b69",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 2166,
            "upload_time": "2024-11-13T03:55:56",
            "upload_time_iso_8601": "2024-11-13T03:55:56.575022Z",
            "url": "https://files.pythonhosted.org/packages/e5/b3/c33acb652c69dde5ec17917d9b0b8ec046d9d08d2e246a9eb197acab3c30/reflex_global_hotkey-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fb20ee0f3ddd67c3465a82b98f581a1809d7b04b0506cb403960e707b9f3dce2",
                "md5": "84b20e4d92f026f1f797ffe77696711c",
                "sha256": "11e3bdc0795ce3e55a69119934ea07773eb32ce5e7c5c34c53fa2c7c1e68a58d"
            },
            "downloads": -1,
            "filename": "reflex_global_hotkey-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "84b20e4d92f026f1f797ffe77696711c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 1710,
            "upload_time": "2024-11-13T03:55:58",
            "upload_time_iso_8601": "2024-11-13T03:55:58.309812Z",
            "url": "https://files.pythonhosted.org/packages/fb/20/ee0f3ddd67c3465a82b98f581a1809d7b04b0506cb403960e707b9f3dce2/reflex_global_hotkey-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-13 03:55:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "adhami3310",
    "github_project": "reflex-global-hotkey",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "reflex-global-hotkey"
}
        
Elapsed time: 0.47118s