getch2: Handle setupterm errors

setupterm abort()s if it can't initialize the terminal and the last
parameter is NULL; handle setupterm errors and retry with "ansi" if
the TERM env var was unset.
getch2: Only send ESC if it was typed twice

Avoids quitting mpv if any unknown escape is entered.