getch2: Put terminal in the proper mode, rely more on termcap

All unmodified keys on a PC105 keyboard running in mintty are now served
by our partial termcap database.

Thanks to DEC, programs running in terminals since the vt100 (and its
emulators, such as xterm, and everything else emulates xterm...) have to
put the terminal in a specific mode called "application mode" in order
to properly receive keys from the numpad and screen control block
(including arrow keys). These are the termcap entries "ks" and "ke".

We enter the application mode when initializing getch2 and exit it when
deinitializing. It's during application mode that some keys have an "O" in
them after the ESC instead of "[".