cleaned up key/mouse handling