Closed tobyMickelson closed 1 year ago
try this instead,
from blessed import Terminal
term = Terminal()
print(f"{term.home}{term.black_on_skyblue}{term.clear}")
with term.cbreak():
while True:
inp = term.inkey()
if inp == 'q':
break
if inp.name == "KEY_LEFT":
print("You pressed left")
the inp
variable was never re-assigned after the first key is pressed, so it was always displaying the first key that was pressed
Thanks for the help, but now it only works with raw but not cbrake.
Traceback (most recent call last):
File "/Users/Username/Documents/Python/test.py", line 7, in <module>
with term.cbrake():
AttributeError: __enter__
shell returned 1
Press ENTER or type command to continue
BTW, this is also a school issued MacBook, and that might be causing some of the problems.
Try term.cbreak()
. There was a typo in the example.
Thank you for helping fix my stupid typo.
When using
with term.cbrake():
, I am unable to get usable input. It starts by not accepting input then thinks every input isKEY_LEFT
.Here is what I tested arrow key input with:
I also tested it with
term.raw()
System information: MacOS Monterey 12.6.1 (21G217) Python 3.10.5 (v3.10.5:f377153967, Jun 6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin