Asynchronous keyboard input
Project description
askin
Asynchronous Keyboard Input
askin is a Python package that provides a simple way to get keyboard input asynchronously.
Installation
pip install askin
Usage
from askin import KeyboardController
class KeyState:
def __init__(self) -> None:
self.value = 0
async def update(self, key: str) -> None:
if key == "a":
self.value += 1
elif key == "b":
self.value -= 1
async def key_handler(key: str) -> None:
key_state.update(key)
async def default() -> None:
print("Default! Resetting value to 0")
key_state.value = 0
async def main() -> None:
key_state = KeyState()
controller = KeyboardController(key_handler=key_state.update, default=default, timeout=0.001)
await controller.start()
try:
while True:
print(key_state.value)
await asyncio.sleep(0.1)
finally:
await controller.stop()
if __name__ == "__main__":
asyncio.run(main())
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
askin-0.0.2.tar.gz
(5.3 kB
view details)
File details
Details for the file askin-0.0.2.tar.gz.
File metadata
- Download URL: askin-0.0.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13de3cc748c65aeae2608679fa4f3f43ad67b0f54d0d5651f7389686891c3767
|
|
| MD5 |
2597dec86bb75cd5a645ab0508707fa6
|
|
| BLAKE2b-256 |
c22cfda3a5c697a006f9bbb08fb4d9add070f56bdd372b0ee92bbba40901aaa6
|
Provenance
The following attestation bundles were made for askin-0.0.2.tar.gz:
Publisher:
publish.yml on WT-MM/asKin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
askin-0.0.2.tar.gz -
Subject digest:
13de3cc748c65aeae2608679fa4f3f43ad67b0f54d0d5651f7389686891c3767 - Sigstore transparency entry: 213087901
- Sigstore integration time:
-
Permalink:
WT-MM/asKin@7d7563beb082dda17ba2308e6836e283c26d7463 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/WT-MM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d7563beb082dda17ba2308e6836e283c26d7463 -
Trigger Event:
release
-
Statement type: