Check out example codes for "if get key down unity". It will help you in understanding the concepts better.

Code Example 1

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

Code Example 2

Input.GetKey(KeyCode.Space))

Code Example 3

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;
        }
    }
}

Code Example 4

using UnityEngine;
using System.Collections;

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

Learn ReactJs, React Native from akashmittal.com