impl keyboard key press, refactor test helpers