Version: 2022.3
public static bool GetKeyUp (string name);

描述

在用户释放 name 标识的键的帧期间返回 true。

Call this function from the Update function, since the state gets reset each frame. It will not return true until the user has pressed the key and released it again.

有关键标识符的列表,请参阅传统游戏输入。 处理输入时,建议改用 Input.GetAxisInput.GetButton,因为这允许终端用户对键进行配置。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { if (Input.GetKeyUp("space")) { print("Space key was released"); } } }

public static bool GetKeyUp (KeyCode key);

描述

在用户释放 key KeyCode 枚举参数标识的键的帧期间返回 true。

using UnityEngine;

public class Example : MonoBehaviour { void Update() { if (Input.GetKeyUp(KeyCode.Space)) { print("space key was released"); } } }