update repository
[cmdllinux.git] / example_n_useful / utils / readkeyc.c
blob9289ce6c2d3887f8f33e4147f74a9dac963885a9
1 #include <curses.h>
3 int
4 main(void)
6 int ch;
7 const char *result;
8 char buffer[80];
10 filter();
11 newterm(NULL, stderr, stdin);
12 keypad(stdscr, TRUE);
13 noecho();
14 cbreak();
15 ch = getch();
16 if ((result = keyname(ch)) == 0) {
17 /* ncurses does the whole thing, other implementations need this */
18 if ((result = unctrl((chtype)ch)) == 0) {
19 sprintf(buffer, "%#x", ch);
20 result = buffer;
23 endwin();
24 printf("%s\n", result);
25 return 0;