Version: 2022.2

描述

Return 键。

用于接受一行文本的键。osMac 将此键称为 /Return/。PC 将此键称为 /Enter/。没有 /KeyCode.Enter/。在 PC 上使用 Return。某些笔记本电脑的 ReturnEnter 键上没有名称。

// KeyCode.Return example.
//
// Attach this to a GameObject.
// This script tells when the Return key is pressed down and when it is released.

using UnityEngine;

public class Example : MonoBehaviour { void Update() { //Detect when the Return key is pressed down if (Input.GetKeyDown(KeyCode.Return)) { Debug.Log("Return key was pressed."); }

//Detect when the Return key has been released if (Input.GetKeyUp(KeyCode.Return)) { Debug.Log("Return key was released."); } } }