Detect Text in GUI; Print

Hello, I have a bit of a compound question. With the below script, is it possible to detect what the user has input only AFTER he has pressed enter, then detect that value and print IN THE SAME GUI TEXT? Thanks everyone who can help.

My script:

var stringToEdit : String = "Hello World";
var TextStyle = new GUIStyle();

function OnGUI () {
    
    stringToEdit = GUI.TextField(Rect(0,0,Screen.width,Screen.height), stringToEdit, 1000000000, TextStyle);
    
    
}

I did actually look into this method (below) but it detected it before I pressed enter.

 if (stringToEdit == "TEST" && Input.KeyCode.Return) {
    
    print("Recieved");
    
    }

var stringToEdit : String = “Hello World”;
var TextStyle = new GUIStyle();

var typing : boolean = false;
 
function OnGUI () 
{
    if(Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && !typing)
        typing = true;
    else if(Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && typing)
        typing = false;

    var temp : String = stringToEdit;

    stringToEdit = GUI.TextField(Rect(0,0,Screen.width,Screen.height), stringToEdit, 1000000000, TextStyle);

    if(!typing)
        stringToEdit = temp;
}