I write a small program about B-Trix. And I want to use getch() to get gamer's input. I try to get the value of up,down,right,left key-press by using getch(), here is my test code:
#include <stdio.h>
#include <curses.h>
int main(void)
{
int ch;
initscr();
printw("Input a character:");
ch = getch();
printw("\nYou input a '%c'\n%d", ch, ch);
refresh();
sleep(3);
endwin();
return 0;
}
the outputs of up down left right are 27, why are these value same? Could anybody help me?
The arrow keys were encoded by three characters in Ubuntu. So I changed my code like this to check arrow keys.