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.3.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.3-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: onkeypress-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 c18804841fcbdf443e870eeb95357ff0ce193644eb30f598c9df06d64454ecab
MD5 ed03bf48d6ece354414a653a7db57fd6
BLAKE2b-256 c97630bc2ae0361d7d4a59f61d94577de063ea168bf367102507d58798e564c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: onkeypress-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 77152277d5bf1be015a384e1aace201c01d3399f95e66634a4a6c76bd0fc061a
MD5 289f886a2ba02ee2558008da1706921e
BLAKE2b-256 d5ca36c7d42290ed67e21fcbab64359913ae10f0199cbfb649238b82b42292fd

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