Repair some lua test samples and modify handle_key_input function