12
我有一个问题,NCURSES ...我需要处理像Esc键,Alt键 + ˚F等 问题是,代码是相似的所有键.. 。即:NCURSES和ESC,ALT键
Esc键 - 27
Alt键 + 甲 - 27 65
作为一个例子存在用于Alt键 + [键]组合什么类似到Esc键键... 任何双码想法如何处理?
我有一个问题,NCURSES ...我需要处理像Esc键,Alt键 + ˚F等 问题是,代码是相似的所有键.. 。即:NCURSES和ESC,ALT键
Esc键 - 27
Alt键 + 甲 - 27 65
作为一个例子存在用于Alt键 + [键]组合什么类似到Esc键键... 任何双码想法如何处理?
通过解决:
这里是一个python的例子:
key = self.screen.getch()
if key == ord('q'): # quit
go = False
elif key == 27: # Esc or Alt
# Don't wait for another key
# If it was Alt then curses has already sent the other key
# otherwise -1 is sent (Escape)
self.screen.nodelay(True)
n = self.screen.getch()
if n == -1:
# Escape was pressed
go = False
# Return to delay
self.screen.nodelay(False)
如果用户点击“ESC”,然后再选择另一个键,比如'['',例如,一个接一个很快,我们的代码不能看到两个键都会通过,然后它不会看起来像' ESC'_?因为我真的不知道终端会如何知道在我第二次打电话时想要收集下一个字符,我试图确定是否只是“ESC”被击中了?! – 2018-01-16 05:24:46