Keypress and proper sorting