/* http://www.cyut.edu.tw/~ckhung/b/mi/ */
/* 1999-06 */
/* how to compile: gcc -Wall getch.c -lncurses */

#include <ncurses/curses.h>
#include <stdio.h>

int main()
{
    int c, i;
    char msg[50];

    initscr();
    cbreak();
    noecho();
    mvaddstr(0, 0, "press 'q' or 'Q' to quit\n");
    c = getch();
    i = 0;
    while (c != 'q' && c != 'Q') {
	sprintf(msg, "You pressed %c (%02x)   ", c, c);
	mvaddstr(i+2, 0, msg);
	c = getch();
	i = (i + 1) % 10;
    }
    endwin();
    return 0;
}

