Library to easily read single chars and key strokes
Low maintenance activity. Last release 8 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install readcharpython-readchar
Library to easily read single chars and keystrokes.
Born as a python-inquirer requirement.
Installation
simply install it via pip:
pip install readchar
Or download the source code from PyPi.
Usage
Simply read a character or keystroke:
import readchar
key = readchar.readkey()
React to different kinds of key-presses:
from readchar import readkey, key
while True:
k = readkey()
if k == "a":
# do stuff
if k == key.DOWN:
# do stuff
if k == key.ENTER:
break
Documentation
There are just two methods:
readchar.readchar() -> str
Reads one character from stdin, returning it as a string with length 1. Waits until a
character is available.