【发布时间】:2023-08-27 21:52:01
【问题描述】:
我需要在 Python 中捕获 TAB 键。对于我做的任何其他键:
x = self.myscreen.getch()
if( x == curses.KEY_DOWN ):
# and so..
TAB 键的常量是什么?我搜索了here(页面底部)并尝试了每个 TAB 内容。
我也试过'\t'。是否可以?谢谢
【问题讨论】:
我需要在 Python 中捕获 TAB 键。对于我做的任何其他键:
x = self.myscreen.getch()
if( x == curses.KEY_DOWN ):
# and so..
TAB 键的常量是什么?我搜索了here(页面底部)并尝试了每个 TAB 内容。
我也试过'\t'。是否可以?谢谢
【问题讨论】:
试试:
if ( x == ord('\t')):
...
或
if ( x == 9):
...
在与 getch 中的值进行比较之前,您需要确保使用 ord() 将字符转换为整数
【讨论】:
试试this,它看起来像你的要求
【讨论】: