handle arrow keys and F keys properly in curses