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 byord
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.
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
Built Distribution
File details
Details for the file python_yakh-0.3.2.tar.gz
.
File metadata
- Download URL: python_yakh-0.3.2.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2833a4c00d9823b1e3b517b71bfcb672f81d4e9719f4326389cef38f5b1bfe3 |
|
MD5 | a08fe60a8e791bbfef2750fe1b753c4f |
|
BLAKE2b-256 | 94471c5246b7444fa1ed97bc54674ccdc46d77d2e160d9f042894a9ceaaf7a90 |
File details
Details for the file python_yakh-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: python_yakh-0.3.2-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18e526e11fbd185a0da98581b8b08d3848bef97b070590fcd5ec49de0893371e |
|
MD5 | f4963feb1000297af38b18c907e6ecdb |
|
BLAKE2b-256 | 6d461c9fe7bba42d293d0447fe3d41f7f021b4268a2583d372e07ea14fc561bc |