Detect Keyboard Event in C
问题 How can I detect keyboard event in C language without using third party libraries? Should I use signal handling? 回答1: There's not a standard way, but these should get you started. Windows: getch(); Unix: Use this code from W. Richard Stevens' Unix Programming book to set your terminal in raw mode, and then use read(). static struct termios save_termios; static int term_saved; int tty_raw(int fd) { /* RAW! mode */ struct termios buf; if (tcgetattr(fd, &save_termios) < 0) /* get the original