Closed Vaxeral closed 2 months ago
im in raw mode. I saw your other issues and i found that i could use the sequence \x01 for control c for example.
Same thing for me. Variant of the "rich event loop" snippet for reference:
#!/bin/python3
from blessed import Terminal
term = Terminal()
print(f"{term.home}{term.black_on_skyblue}{term.clear}")
print("press 'q' to quit.")
with term.raw():
val = ''
while val.lower() != 'q':
val = term.inkey(timeout=3)
if not val:
print("It sure is quiet in here ...")
elif val.is_sequence:
print("got sequence: {0}.".format((str(val), val.name, val.code)))
elif val:
print(f"got {val}. ({val.code})")
print(f'bye!{term.normal}')
When launching it from Bash, almost all Keystroke
object on Ctrl modifier sequences have a code None
. Some exceptions:
Edit: tried with keymatrix.py, and the code seems to be reported there
What's an example of a key you're seeing in keymatrix that you aren't seeing in the above code?
Hello @Minabsapi,
Try changing,
print(f"got {val}. ({val.code})")
to,
print(f"got {val!r}. ({val.code})")
that is, display repr(val) rather than str(val) -- as the val
in this case is the raw control character. When written to stdout, most terminals do not display anything
Closing as duplicate of #58
Im trying to detect ctrl+c or other variants in my vscode terminal. Ctrl sequences seem to not appear when using inkey.