Skip to main content

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):
        self.value = 0
    async def update(self, key: str):
        if key == "a":
            self.value += 1
        elif key == "b":
            self.value -= 1

async def key_handler(key: str):
    key_state.update(key)

async def main():
    key_state = KeyState()
    controller = KeyboardController(key_handler=key_state.update, 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


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.1.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file askin-0.0.1.tar.gz.

File metadata

  • Download URL: askin-0.0.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for askin-0.0.1.tar.gz
Algorithm Hash digest
SHA256 508c29658144427b568189e5b52b46dc3e99f69ca91f0c56b8680c5faf7e6bbb
MD5 9303636d98bac54566add5100f5e0a89
BLAKE2b-256 4462d9908fcb84c2227bc723d3a238dd78a40440b371cc412d177195990df4c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for askin-0.0.1.tar.gz:

Publisher: publish.yml on WT-MM/asKin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page