Closed vanschelven closed 2 years ago
Hello,
I am working on similar problem over on https://github.com/Cube707/python-readchar/pull/5 and as my experiences with the unix-termianl are limited, your insigt might be helpfull. If you can find the time you may want to take a look.
this PR is no longer relevant in v4.0.0
but discussion on how to deal with this problem continues in the original issue
Calling
tty.setraw
makes it so that subsequent calls toread()
don't read any of the typed-but-not-read characters. Reading the code, this could be expected sincetty.setraw
is called without explicit parameters, and the default for when isTCSAFLUSH
, which means:Indeed, changing the call to be with
TCSADRAIN
seems to solve the problem of missing keystrokes.However, that solves the problem that any keystrokes that occur outside of
readchar
are dropped fully, but it does not solve the problem that they will be echoed. (They will be echoed because they occur at a point in time that stdin is in "cooked" or "canonical" (non-raw) mode).See #73