Textfield doesn't work

So I am trying to make a cheat input for my game, but the only problem is that the text field isn’t taking any inputs.
So how do I make it work?

Here’s my code:

var CheatCode : String;
function OnGUI () {
     var CheatField = GUI.TextField(Rect(10,580,200,20),CheatCode, 25);
}

function Update () {
   if(Input.GetKeyDown(KeyCode.Escape)){
      Time.timeScale = 0;
      GetComponent("MouseLook").enabled = !GetComponent("MouseLook").enabled;
   }
}

Here’s an example of how to use GUI.FocusControl. You also need to set CheatField to use CheatField as content so you can actually edit the Field. You can simply set CheatCode to be equal on some event. In this example, you type in what you want, hit Enter, then your string will be sent to the CheatCode string, clear the CheatField string, then print CheatCode to the console to confirm it was changed.

#pragma strict

var CheatCode : String;
private var CheatField : String = "";

function OnGUI () 
{
	GUI.SetNextControlName("MyTextField");
	CheatField = GUI.TextField(Rect(10,580,200,20), CheatField, 25);
	if(CheatField != "" && Event.current.keyCode == KeyCode.Return)
	{
		CheatCode = CheatField;
		CheatField = "";
		print(CheatCode);
	}
	GUI.FocusControl("MyTextField");
}

But if you want to check if your input matches the CheatCode string set in the inspector, instead, use

#pragma strict

var CheatCode : String;
private var CheatField : String = "";

function OnGUI () 
{
	GUI.SetNextControlName("MyTextField");
	CheatField = GUI.TextField(Rect(10,580,200,20), CheatField, 25);
	if(CheatField != "" && Event.current.keyCode == KeyCode.Return)
	{
		if(CheatField == CheatCode)
			print("Match!");
		else
			print("Invalid Command.");
		CheatField = "";
	}
	GUI.FocusControl("MyTextField");
}