python-yakh


Namepython-yakh JSON
Version 0.3.2 PyPI version JSON
download
home_pagehttps://github.com/petereon/yakh
SummaryYet Another Keypress Handler
upload_time2023-09-29 06:06:58
maintainer
docs_urlNone
authorpetereon
requires_python>=3.7.8,<4.0.0
licenseMIT
keywords python keypress key keyboard
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # yakh

yakh (Yet Another Keypress Handler) tries to handle keypresses from the stdin in the terminal in high-level platform indepdendent manner.

## Installation

Yakh can be installed from [PyPI](https://pypi.org/project/python-yakh/) using,
```sh
pip install python-yakh
```

or GitHub itself using poetry,
```sh
poetry add git+https://github.com/petereon/yakh.git
```

## Usage

```python
from yakh import get_key
from yakh.key import Keys

key = ''
while key not in ['q', Keys.ENTER]:
    key = get_key()
    if key.is_printable:
        print(key)
```

yakh is dead-simple, there is only one function `get_key()` which takes no arguments and blocks until a key is pressed.

For each keypress it creates an instance of [`Key`](./yakh/key/_key.py#L7) which holds:

- `.key`: characters representing the keypress
- `.key_codes`: collection of Unicode code point encodings for all the characters (given by `ord` function)
- `.is_printable`: printability of the characters in the keypress

Additionally `Key` instances

-  are comparable with another `Key` instances, `str` instances and *Unicode code point* representations (tuples of integers)
- come with string representation for purposes of printing and string concatenation, which returns the content of `.key` attribute

## `yakh.key` submodule
`yakh.key` sub-module contains platform dependent representations of certain keys under `Keys` class. These are available namely for `CTRL` key combinations and some other common keys. 

Full list of keys can be seen [here](./yakh/key/_key.py#L42) and [here](./yakh/key/_key.py#L81).


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/petereon/yakh",
    "name": "python-yakh",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.8,<4.0.0",
    "maintainer_email": "",
    "keywords": "python,keypress,key,keyboard",
    "author": "petereon",
    "author_email": "pvyboch1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/94/47/1c5246b7444fa1ed97bc54674ccdc46d77d2e160d9f042894a9ceaaf7a90/python_yakh-0.3.2.tar.gz",
    "platform": null,
    "description": "# yakh\n\nyakh (Yet Another Keypress Handler) tries to handle keypresses from the stdin in the terminal in high-level platform indepdendent manner.\n\n## Installation\n\nYakh can be installed from [PyPI](https://pypi.org/project/python-yakh/) using,\n```sh\npip install python-yakh\n```\n\nor GitHub itself using poetry,\n```sh\npoetry add git+https://github.com/petereon/yakh.git\n```\n\n## Usage\n\n```python\nfrom yakh import get_key\nfrom yakh.key import Keys\n\nkey = ''\nwhile key not in ['q', Keys.ENTER]:\n    key = get_key()\n    if key.is_printable:\n        print(key)\n```\n\nyakh is dead-simple, there is only one function `get_key()` which takes no arguments and blocks until a key is pressed.\n\nFor each keypress it creates an instance of [`Key`](./yakh/key/_key.py#L7) which holds:\n\n- `.key`: characters representing the keypress\n- `.key_codes`: collection of Unicode code point encodings for all the characters (given by `ord` function)\n- `.is_printable`: printability of the characters in the keypress\n\nAdditionally `Key` instances\n\n-  are comparable with another `Key` instances, `str` instances and *Unicode code point* representations (tuples of integers)\n- come with string representation for purposes of printing and string concatenation, which returns the content of `.key` attribute\n\n## `yakh.key` submodule\n`yakh.key` sub-module contains platform dependent representations of certain keys under `Keys` class. These are available namely for `CTRL` key combinations and some other common keys. \n\nFull list of keys can be seen [here](./yakh/key/_key.py#L42) and [here](./yakh/key/_key.py#L81).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Yet Another Keypress Handler",
    "version": "0.3.2",
    "project_urls": {
        "Homepage": "https://github.com/petereon/yakh",
        "Repository": "https://github.com/petereon/yakh"
    },
    "split_keywords": [
        "python",
        "keypress",
        "key",
        "keyboard"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d461c9fe7bba42d293d0447fe3d41f7f021b4268a2583d372e07ea14fc561bc",
                "md5": "f4963feb1000297af38b18c907e6ecdb",
                "sha256": "18e526e11fbd185a0da98581b8b08d3848bef97b070590fcd5ec49de0893371e"
            },
            "downloads": -1,
            "filename": "python_yakh-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f4963feb1000297af38b18c907e6ecdb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.8,<4.0.0",
            "size": 5828,
            "upload_time": "2023-09-29T06:06:57",
            "upload_time_iso_8601": "2023-09-29T06:06:57.290260Z",
            "url": "https://files.pythonhosted.org/packages/6d/46/1c9fe7bba42d293d0447fe3d41f7f021b4268a2583d372e07ea14fc561bc/python_yakh-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "94471c5246b7444fa1ed97bc54674ccdc46d77d2e160d9f042894a9ceaaf7a90",
                "md5": "a08fe60a8e791bbfef2750fe1b753c4f",
                "sha256": "f2833a4c00d9823b1e3b517b71bfcb672f81d4e9719f4326389cef38f5b1bfe3"
            },
            "downloads": -1,
            "filename": "python_yakh-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a08fe60a8e791bbfef2750fe1b753c4f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.8,<4.0.0",
            "size": 4210,
            "upload_time": "2023-09-29T06:06:58",
            "upload_time_iso_8601": "2023-09-29T06:06:58.422910Z",
            "url": "https://files.pythonhosted.org/packages/94/47/1c5246b7444fa1ed97bc54674ccdc46d77d2e160d9f042894a9ceaaf7a90/python_yakh-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-29 06:06:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "petereon",
    "github_project": "yakh",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "python-yakh"
}
        
Elapsed time: 0.37298s