I just started using the asciimatics library, and I want it to take keyboard input. My code thus far is:
from asciimatics import *
import time
def demo(screen):
while True:
x = screen.get_event()
if x:
screen.print_at(str(x), 0, 0)
screen.refresh()
Screen.wrapper(demo)
But when i, say, try to type "e" it gives me this:
KeyboardEvent: 101) 0
It collects these random numbers on keyboard and mouse events. (I only want keyboard events).
I want it to record keyboard input similar to input. Edit: does it need to be something "chr"?
As documented here,
get_event
returnsEvents
. To get the string value of the key pressed, usechr(x.key_code)
if for anyKeyboardEvent
.