How do I detect arrow keys pressed using curses in C?

James picture James · Jul 25, 2009 · Viewed 20.4k times · Source

In trying to get input from the arrow keys via curses (ncurses) it won't catch as KEY_UP etc. I used the keypad function with a true argument but getch still returned an escaped sequence. How do I shift through the values returned by getch() and grab the arrow keys specifically?

Answer

Paul Franz picture Paul Franz · Oct 19, 2009

I found the same problem on Mac OS X. But it was resolved by adding the following:

keypad(stdscr, TRUE);