Returning Which Key Was Pressed

Seems pretty simple but I can’t find an answer anywhere.

All I want to do is get the key pressed.

Debug.Log(Input.string) gives me empty strings or sometimes if I type extra fast a few characters, but a simple keystroke it generally returns nothing. Maybe something to do with execution order.

void Update () 

This is what I have so far. Would have thought it would have just logged the input string. I read somewhere that Input.anyKeyDown was internally invoked after Input.inputString so maybe it’s just some sort of race condition.

Anyway any help would be most appreciated. Cheers :slight_smile:

Because robertu posted his (correct) answer as a comment, I’ll post an alternative solution.

Use Input.anyKey instead of Input.anyKeyDown.