I was learning curses (using Pluto Project PDCurses) when I found out the keypad key definitions doesn't really work.
For example, this program shows nothing after I press the up arrow key on my keyboard.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <curses.h>
int main()
{
int ch;
initscr();
keypad(stdscr, TRUE);
ch = getch();
if(ch == KEY_UP)
printw("IT WORKS!");
getch();
endwin();
return 0;
}
|
After a bit of debugging I learned that up arrow key is interpreted as the number 60419. I tried changing KEY_UP to that number and the program works.
The problem only happens when I test the value of ch with non ASCII characters. I did everything on CodeBlocks in a Windows machine.
I have two questions about this:
1. What is this number? I know it's not ASCII or Alt Codes. I tried Google but I got a bank somewhere in England.
2. If this is system related, should I mess around with curses.h file to associate every key with this number? I think this is a really really bad idea.
For reference, I tried to check what number is associated with each arrow key and this is the result
http://puu.sh/jnzF0.JPG (top to bottom: a, s, d, f, g, h, j, k, l, ;, up arrow, right arrow, down arrow, left arrow, up arrow, right arrow, down arrow, left arrow)
Curses are weird.