Blaskovic
Blaskovic

Reputation: 356

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

Upvotes: 5

Views: 5232

Answers (2)

Craig
Craig

Reputation: 4840

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

Upvotes: 7

enrique2334
enrique2334

Reputation: 1059

Try this it looks like what your asking For

Upvotes: -3

Related Questions