Using curses to handle keys and event