optimize performance, only emit events after player presses keys