Crashfix in keyboard event