'How do I get Input to read other keys and not just Up and Down

I saw some codes like this:

if (Input.GetKey(KeyCode.UpArrow)) 

and

if (Input.GetKey(KeyCode.UpArrow))

Wanted to know how do I put other keys, as in the case of the "a"

 if (Input.GetKey(KeyCode.AArrow))

tried this code here however it gives an error, as I write?



Solution 1:[1]

When using KeyCode in comparison (like an if statement) you must call the specific keycode you want to compare the input to. Microsoft has documentation which provides the standard KeyCodes represented in System.Windows which most, if not all, external libraries call to.

So in this case you need to check for the A key specifically.

if (Input.GeyKey(KeyCode.A))
{
    //code runs if and only if the input key is the A key
}
else if (Input.GetKey(KeyCode.Escape))
{
    //code runs if and only if the input key is the ESC key.
}

Now if you want many possible inputs at a specific time you may not wish to use an if statement, but I would recommend trying this out first to see if you get better results.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ExplodatedFaces