Keyboard input refactor