curses problem reading cursor keys

Simon Morgan me at
Sat Oct 7 09:12:33 EDT 2006


I'm having trouble with the following code. The problem is that the value
read by getch() when I hit the up or down keys doesn't match curses.KEY_UP
or curses.KEY_DOWN respectively. Other keys, such as 'z' in my example
code, work fine.

I only seem to have this problem when dealing with newly created windows
and not with the standard/default/root one created by curses.wrapper() and
passed to main().

I'd also appreciate any pointers to good tutorials on curses, I've read
the one by awk and esr but found it rather brief and lacking in detail.


import curses

def main(scr):
    status = curses.newwin(1, curses.COLS, 0, 0) status.bkgd('0')

    list = curses.newwin(curses.LINES, curses.COLS, 1, 0) list.bkgd('X')

    y = 0
    while True:
        c = list.getch()
        if c in (curses.KEY_UP, curses.KEY_DOWN, ord('z')):
        elif c == ord('q'):


More information about the Python-list mailing list