move keycodes out of the event handler