How to enable/disable scripts on keyboard input (java)?

Sorry for the amateur question, but I just can’t figure out to get this script working. Our basic setup is a first person mode and once the escape key is pressed, the mouse orbit is disabled (so users can click on the search bar without moving the camera). What would I need to add for the escape key to re-enable the mouse orbit (and disable the search bar)?

#pragma strict

var script : dropDownList;
var script2 : MouseOrbit;

function Start () {

	script = GetComponent(dropDownList); //change the name in the bracket to match the name of the search bar script
	script.enabled = false;
	
	script2 = GetComponent(MouseOrbit);
	script2.enabled = true;
	
}

function Update () {

	if(Input.GetKey(KeyCode.Escape)) { //key code can be changed to a different key
		script = GetComponent(dropDownList);
		script.enabled = true; 
		
		script2 = GetComponent(MouseOrbit);
		script2.enabled = false;}

		
}

Thanks in advance

Try this:

function Update () {
 
    if(Input.GetKey(KeyCode.Escape)) { //key code can be changed to a different key
       script = GetComponent(dropDownList);
       script.enabled = !script.enabled; 
 
       script2 = GetComponent(MouseOrbit);
       script2.enabled = !script2.enabled;
    } 
}