我有NCurses的问题...我需要处理所有的密钥,如Esc,Alt + F等。问题是代码是相似的...即:
Esc - 27
Alt + A - 27 65
作为一个例子,Alt + [key]组合的双重代码类似于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)
解决方案: