我刚开始使用asciimatics库,我想要它接受键盘输入。到目前为止,我的代码是:
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)但当我试着键入"e“时,它会给我这样的印象:
KeyboardEvent: 101) 0它在键盘和鼠标事件上收集这些随机数字。(我只想要键盘事件)。
我希望它记录键盘输入类似于输入。编辑:它需要是"chr“吗?
发布于 2020-09-05 18:04:22
如文档所示,这里返回Events。若要获取按下的键的字符串值,请对任何chr(x.key_code)使用KeyboardEvent。
https://stackoverflow.com/questions/61497252
复制相似问题