Use getch() from the ncurses library.