Yet Another Keypress Handler
Project description
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 using,
pip install python-yakh
or GitHub itself using poetry,
poetry add git+https://github.com/petereon/yakh.git
Usage
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 which holds:
.key: characters representing the keypress.key_codes: collection of Unicode code point encodings for all the characters (given byordfunction).is_printable: printability of the characters in the keypress
Additionally Key instances
- are comparable with another
Keyinstances,strinstances and Unicode code point representations (tuples of integers) - come with string representation for purposes of printing and string concatenation, which returns the content of
.keyattribute
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_yakh-0.4.1.tar.gz.
File metadata
- Download URL: python_yakh-0.4.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da03e800b4f2f5d85344f1668e852687c12dc1a99a03c65cf3dc13a3680da49d
|
|
| MD5 |
6633fa282a8612e65a2dc3766fc0afff
|
|
| BLAKE2b-256 |
d277bbff0a1e6fb03b8cc2cc373a44cfbbb4fd22863c657f8630f4a0f5eb207c
|
File details
Details for the file python_yakh-0.4.1-py3-none-any.whl.
File metadata
- Download URL: python_yakh-0.4.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d69507e13e03d09cefd88030f74b6d5369b67de004be975a35be28eb286122e4
|
|
| MD5 |
554ef83c58720caa99e76b3f9371f67b
|
|
| BLAKE2b-256 |
224272571b24514b5f59c328f12e5294b246958951b889fac2bd5321e08a4bab
|