Skip to main content

A simple program that allows users to make their terminal reactive to keypresses

Project description

onkeypress

Allows users to make terminal react to keypresses

installation

pip install onkeypress

quickstart

from onkeypress import while_not_exit, onkeypress, Key

def func(key):
    print(f"{key} was pressed")

while_not_exit(
    onkeypress(Key.UP).invoke(func, ["up"]),
    onkeypress(Key.DOWN).invoke(func, ["down"]),
    onkeypress("a").invoke(func, ["a!!"]),
    onkeypress("s").invoke(func, ["s!!"]),
    exit_key=Key.ENTER,
)

^ after running this, your terminal now waits for your keypresses

  • if you hit ArrowUp, it prints "up was pressed"
  • if you hit ArrowDown, it prints "down was pressed"
  • if you hit "a", it prints "a was pressed"
  • if you hit "s", it prints "s was pressed"
  • if you hit Enter, this function ends

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

onkeypress-0.0.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onkeypress-0.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file onkeypress-0.0.2.tar.gz.

File metadata

  • Download URL: onkeypress-0.0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for onkeypress-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c2d84d50e891c3ccb6677853141b9c96f5cbc808000db6536f11b37ac4e8d29b
MD5 32a6d3bc56a62c01e94abe45a2ed071a
BLAKE2b-256 adad182ca49db37ba2cf46a6ad68fb4fc7b64918f7611735402af6a182cdddbd

See more details on using hashes here.

File details

Details for the file onkeypress-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: onkeypress-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for onkeypress-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c40b98e6ca631174645b6ecc58722a3615604094edacdcda3470aa90d14e154
MD5 80845ea63b47a729ae77df7a2b161a9a
BLAKE2b-256 43555919d1c0dc8353e5d2b33603e20dfae8b4222605b8fadc177070734d29e8

See more details on using hashes here.

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