Debug.Log(Input.GetKey)

Code Example - Debug.Log(Input.GetKey)

                
                        void Update()
{
    //get the input
    var input = Input.inputString;

    //ignore null input to avoid unnecessary computation
    if (!string.IsNullOrEmpty(input))
    {
        switch(input)
        {
            case 'a': break;
            case 'b': break;
        }
    }
}
                    
                
 

unity key detection

                        
                                if (Input.GetKeyDown(KeyCode.Space))
        {
            print("space key was pressed");
        }
                            
                        
 

if get key down unity

                        
                                using UnityEngine;
using System.Collections;

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