xxxxxxxxxx
using UnityEngine;
public class InputHandler : MonoBehaviour
{
private void Update()
{
// Check for keyboard input
if (Input.anyKeyDown)
{
string key = GetKeyPressed();
Debug.Log("Key pressed: " + key);
// Handle the key input according to your requirements
// For example, you could send it to a text field, update a UI, etc.
}
}
private string GetKeyPressed()
{
foreach (KeyCode keyCode in System.Enum.GetValues(typeof(KeyCode)))
{
if (Input.GetKeyDown(keyCode))
{
return keyCode.ToString();
}
}
return "";
}
}