Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python curses - can't get TAB key

I need to catch TAB key in Python. For any other keys I do:

x = self.myscreen.getch()
if( x == curses.KEY_DOWN ):
  # and so..

What's the constant for TAB key? I searched here (bottom of page) and tried every TAB contant.

I tried '\t' too. Is it possible? Thank you

like image 587
Blaskovic Avatar asked Oct 09 '22 15:10

Blaskovic


1 Answers

Try:

if ( x == ord('\t')):
    ...

or

if ( x == 9):
    ...

You need to be sure to convert the character to an integer with ord() before comparing to the value from getch

like image 87
Craig Avatar answered Oct 12 '22 09:10

Craig