#define NCURSES_WIDECHAR 1 #include #include #include static struct pollfd fds[1]; int main() { SCREEN *term; WINDOW *win; int c; int line = 10; term = newterm(termname(), stdout , stdin); win = newwin(5, 20, 5, 5); noecho(); clear(); cbreak(); keypad(stdscr, TRUE); keypad(win, FALSE); /* * Workaround - after uncomment, the code * will work as expected. * keypad(stdscr, TRUE); */ timeout(0); fds[0].fd = fileno(stdin); fds[0].events = POLLIN; mvprintw(8, 10, "try to press KEY DOWN (or any key or q)"); refresh(); while (1) { wint_t ch; int poll_num; poll_num = poll(fds, 1, -1); (void) get_wch(&ch); c = ch; if (c == 'q') break; mvprintw(line++, 10, "pressed \"%s\" (%d)", keyname(c), c); clrtoeol(); refresh(); } endwin(); }