Closed eddawley closed 2 years ago
Noticed a similar issue with other keys as well. Whenever I run readkey more than once in the same code it only gets the key in the first call. Example below.
-- test.py (pressing a, b, c, d on each run)
import readchar as rc
i=0
while i < 4:
i+=1
print("{0}# Press a key".format(i))
key = rc.readkey()
print("Key is {0}".format(key))
-- output
Key is a
2# Press a key
Key is None
3# Press a key
Key is None
4# Press a key
Key is None
Noticed this when debugging an issue with python-inquirer. readkey() will only return the first byte of arrow keys when stdin is unbuffered (either from PYTHON_UNBUFFERED or explicitly setting sys.stdin to unbuffered file object).
output (keypresses up, right, down, left):