Getting multiple errors for input key presses


I don’t know what the issue is. Any help is appreciated.

Hi Marcus,

The only issue you have is that you have KeyCode.UpArrow within quotation marks. You only need to do that if you are specifying the name, as a string, for the key. If you are providing the actual keycode, as you are, you don’t need them.

So, it’s a nice easy win, just update to this;

void Update()
{
    if(Input.GetKeyDown(KeyCode.UpArrow))
    {
        print("Up arrow pressed");
    }
    if(Input.GetKeyDown(KeyCode.DownArrow))
    {
        print("Down arrow pressed");
    }
}

Note, it is usually better to copy/paste your code into the topics rather than using screenshots as it means that those who help can copy/paste chunks of your code back for you without having to type it all out. :slight_smile:

To format the code nicely you just need to enter some formatting characters before and after it and the forum will do the rest.

Screenshots for details from the actual Unity editor can be beneficial though, error message or details from the Hierarchy/Inspector etc.

Also, welcome to the community! :slight_smile:


See also;

Thanks a lot! This was a life saver.

1 Like

No problem at all, you’re very welcome :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms