Fix to keyboard input handling