magmax / python-readchar

Python library to read characters and key strokes
MIT License
149 stars 45 forks source link

ESC doesn't work on its own on posix #94

Open Cube707 opened 2 years ago

Cube707 commented 2 years ago

Pressing the ESC key on posix systems will not be returned by readkey().

This is expected as it, as the name implies, escapes the next char. It is used to mark longer sequence of multiple keys. readchar can't know the difference if it stems from a single press of ESC or if it is the beginning of a longer sequence.

Use readchar() instead, which correctly returnes every charater seperatly (but you have to handle multiple char-keys yourself, ARROWS, etc..)

Cube707 commented 2 years ago

One option would be to implement a timeout on reads. This would require #92 to be merged and enable non-blocking reads, so that a timer could be checked again in parallel to waiting for the next char