For assigning custom or unknown input values from a Joystick/Throttle or a key pad, how can I get the key that the player pressed? How can I Debug.log the value of whatever input Unity finds? For example, Debug.Log(Input.anyKey.ToString()); returns True or False, but how can I have it return ‘space’ if I press the spacebar?
I’ve written up a quick script for you:
using UnityEngine;
public class InputTest : MonoBehaviour {
private void Update() {
foreach (KeyCode keyCode in System.Enum.GetValues(KeyCode)) {
if (Input.GetKeyDown (keyCode)) {
Debug.Log ("Current input key:" + keyCode.ToString());
}
}
}
}