TextField not clear after focusing it through a Key

Greetings unity community,

I have a chat field that is represented by a GUI.Window and a TextField at the bottom of that window.

function OnGUI() {
	window = GUI.Window(1, window, GlobalChatWindow, "Chat");
}

function GlobalChatWindow(id : int) {
   /*here be actual chat window logic etc, not really important as it works*/

    //sets the control name
	GUI.SetNextControlName("chatField");

        //creates an actual field
	inputField = GUILayout.TextField(inputField);

        //getting focus when pressing the 'T' button	
    if (Input.GetKeyDown(KeyCode.T)) {		
		GUI.FocusControl ("chatField");	
	}
}

The problem hereby is, that the inputField takes on the ‘t’ string and I can’t seem to delete that t as the logic records it when I’m out of the if logic already.

Say the TextField is unfocused and I’m running around ingame.
Then I press ‘T’.
The field gets focused but with the content ‘t’ which I have to delete manually afterwards.

How do I get rid of this? inputField = “”; either doesn’t work at all (when inside the if logic) or too good and blocks all chatting when outside the if logic.

Greetings, Cirrus

Here is an alternate solution. I cannot say it is better:

function OnGUI() {
 	var e = Event.current;	
 	
	window = GUI.Window(1, window, GlobalChatWindow, "Chat");

        //getting focus when pressing the 'T' button 
    if (e.type == EventType.KeyUp && e.keyCode == KeyCode.T && GUI.GetNameOfFocusedControl() != "chatField") {   
		inputField = "";
        GUI.FocusControl ("chatField"); 
        focused = true;
    }
}
 
function GlobalChatWindow(id : int) {
 /*here be actual chat window logic etc, not really important as it works*/
    GUI.SetNextControlName("chatField"); 
    //creates an actual field
    var st = GUILayout.TextField(inputField);
    // Don't save the string if we don't have focus
    if (GUI.GetNameOfFocusedControl() == "chatField")
    	inputField = st;   
}