Text field Read Enter button

ok so i’m having a problem which i have almost given up on

here is the script i use to generate a question and a text field

GUI.color = Color.yellow;

   GUI.backgroundColor = Color.yellow;

  GUI. Window (0, Rect (200,10,400,140), DoWindow, " what the password ");
   
  stringToEdit = GUI.TextField (Rect (200, 150, 400, 50), stringToEdit, 200);

I have been trying to have the answer i put in read when i press the enter key
but i am unable to do it .
i know some functions are missing , would someone please help me with this.
thanks in Advance .

When the player press enter, which can be detected from Update (Input.GetKey…) or from the GUI (if(Event.current.isKey && Event.current.keyCode … )), do whatever you need to do with stringToEdit and stop displaying the TextField.