Fix crash when abnormal keys are pressed.