basically what I am trying to do is to save information what the user types in the Input Field and displays it it when they press Return instead of the button. Most tutorials use buttons, and not keypress. I prefer it to be in C# Thanks
Asked
Active
Viewed 823 times
-1
-
What have you done so far? Paste code snippet. – Dr.jacky Jan 15 '17 at 06:01
1 Answers
1
If you want to call methods/trigger event when a key is pressed, you can do this:
public class ClassA : MonoBehaviour {
void Update() {
if (Input.GetKeyDown(Keycode.Space))
// call your method
}
}
You can read about this here: https://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html

Gergő Tamási
- 46
- 2
-
1`Input.GetKeyDown` is not appropriate to be used with `InputField`. I have a a feeling that OP wants to detect when user is done typing after pressing the Enter/Return key. This should be done by subscribing to the `onEndEdit` event. – Programmer Jan 15 '17 at 10:00