查看按下的按键的值

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class KeyCodeDemo : MonoBehaviour {

    public Text text;
    void Update()
    {
        if (Input.anyKeyDown)
        {
            foreach (KeyCode keyCode in Enum.GetValues(typeof(KeyCode)))
            {
                if (Input.GetKeyDown(keyCode))
                {
                    text.text = "Current Key is : " + keyCode.ToString();
                }
            }
        }


    }
}
原文地址:https://www.cnblogs.com/Feiyuzhu/p/13476390.html