typeahead
curses does “line‐breakout optimization” by looking for typeahead
periodically while updating the screen. If input is found, and it
is coming from a terminal, the current update is postponed until
refresh(3NCURSES) or doupdate is called again. This allows faster
response to commands typed in advance. Normally, the input FILE
pointer passed to newterm, or stdin in the case that initscr was
used, will be used to do this typeahead checking. The typeahead
routine specifies that the file descriptor fd is to be used to
check for typeahead instead. If fd is -1, then no typeahead
checking is done.