"getch2" really tells nothing about what the heck this code does. It'd be even worse when moving the rest of terminal handling code there.