Don't double post. There's an "edit" button for a reason.
Also, the source code you found/posted is terrible. It isn't standard C (cout?), it uses all outdated headers, and, as you said, the value of the arrow keys isn't represented by 72, 75, 77, and 80.
I wrote a quick test (note: WON'T WORK IF NOT *NIX) to determine the *real* value of the escape codes that represented an arrow:
Code:
int ch, i;
struct termios term;
tcgetattr( STDIN_FILENO, &term );
term.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &term );
for (i = 0; i < 4; i++) {
puts("enter arrow");
ch = getchar() & 0xFF;
ch += getchar() & 0xFF;
ch += getchar() & 0xFF;
printf("%c | %d\n", ch, ch);
}
This took the (usually 3) characters that represent an arrow, and captured them all. The result:
Code:
enter arrow
? | 183
enter arrow
? | 184
enter arrow
? | 185
enter arrow
? | 186
In order: up, down, left, right.