Python Forum

Full Version: curses key codes not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am attempting to use curses in python. I am finding that the keycodes are
possibly not correct.

here is some sample code I'm using to test the keys

stdscr.keypad(True)
c = stdscr.getch()
if c == curses.KEY_ENTER:
using this code, str(hex( c )) equals 0xa
and the value of str(hex(curses.KEY_ENTER)) equals 0x157
and the value of str(int(curses.KEY_ENTER)) equal 343

so a test like this is never true

if c==curses.KEY_ENTER:

will not work

I know I can test using another way. I'd prefer to use those constants

I found that tests for curses.KEY_LEFT and curses.KEY_RIGHT do work and the test for curses.KEY_BACKSPACE does not work