using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public KeyCode getKeyDownCode()
{
if (Input.anyKeyDown)
{
foreach (KeyCode keyCode in Enum.GetValues(typeof(KeyCode)))
{
if (Input.GetKeyDown(keyCode))
{
Debug.Log(keyCode.ToString());
return keyCode;
}
}
}
return KeyCode.None;
}
void Update()
{
getKeyDownCode();
}
}
就用一个方法
void OnGUI()
{
if (Input.anyKeyDown)
{
Debug.Log(Event.current.keyCode);
}
}