Light rarely turns on

I’ve got a trigger box, which is the region of the light switch. However, this only works sometimes for some odd reason.

using UnityEngine;
using System.Collections;

public class TriggerTest : MonoBehaviour {

private Light myLight;

private void Start() 
{
	myLight = GetComponent<Light> ();
}

void OnTriggerEnter (Collider other)
{
	if (Input.GetKey(KeyCode.F))
	{
		myLight.enabled = true;
	}
	if (Input.GetKey (KeyCode.G)) 
	{
		myLight.enabled = false;
	}
}

}

Currently, you have to press and hold F and then approach the Trigger to turn on the lights. OnTriggerEnter only runs once when you enter the trigger. You are limited to only that single frame to interact with the lights. After that, you would have to leave and enter the Trigger again to interact with the lights again.

I assume the Trigger is like an area where you can interact with the switch. In which case, it’s probably better to use OnTriggerStay(). This means as long as you are in the Trigger, you can press F and G to interact with the lights.