File descriptor of getch()
问题 I want to use libev to listen for keyboard (keystrokes) events in the terminal. My idea is to use (n)curses getch() and set notimeout() (to be nonblocking) to tell getch() not to wait for next keypress. Is there a file descriptor that getch uses I can watch? 回答1: If you use initscr() , the file descriptor you ask for is fileno(stdin) , since the initscr subroutine is equivalent to: newterm(getenv("TERM"), stdout, stdin); return stdscr; If you use newterm(type, outfile, infile) , the file