TextField plus Return Key issue

I have a TextField that represents the user´s login info, a button to make the login but I also want the Return key to do the same as the button. The problem is that it will only work if I click outside of the TextField for once it´s focused, Input.GetKey(KeyCode.Return) will no longer work.

I am aware of GetNameOfFocusedControl and FocusControl but I was unable to use any of those together with Input.GetKey(KeyCode.Return).

Any suggestions?


Hey there,

Very similar question was answered here recently. Don’t worry, there’s no need for GUI.FocusControl (although you’ll probably need it eventually :D) …

Hope this helps, Klep

Here is an example: