refactored keypress handling