/* * Get and echo keys, with "bold" attribute. * * Functions are mostly from ncurses library. "man 3x foobar" to find out * what foobar() does. */ #include #include int prompt_and_get_ch(void); int main(void) { int ch; initscr(); raw(); keypad(stdscr, TRUE); noecho(); while ((ch = prompt_and_get_ch()) != KEY_F(2)) { printw("\nThe pressed key is "); attron(A_BOLD); printw("%c", ch); attroff(A_BOLD); } endwin(); return EXIT_SUCCESS; } int prompt_and_get_ch(void) { printw("\nType any character (F2 to end) "); return getch(); }