Keyboard handling improvement