Fixed condition in keypress handler