Python Forum
curses key codes not working - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/Forum-Python-Coding)
+--- Forum: General Coding Help (https://python-forum.io/Forum-General-Coding-Help)
+--- Thread: curses key codes not working (/Thread-curses-key-codes-not-working)



curses key codes not working - jgrillout - Feb-11-2019

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