input.getkeydown dialouge system help

So I’m trying to make a basic dialogue system using on-trigger-enter and i want my character to enter the trigger area and press “f” however when i go in the trigger and press “f” I’m not getting the console message for but i am for when i enter the trigger. After some research it said that the input.getkeydown has to be in the update function but the problem is that even when I’m not in the trigger i can still press f and the console message will appear. How do I make it i can only press f in the trigger

function Update () 
{
	if (Input.GetKeyDown("f"))			
	{
		Debug.Log("f is pressed");
	}
}
function OnTriggerEnter (other : Collider)
{
	if(other.tag == "Player")
	{
		Debug.Log("Press F to Talk");
	}
}

The Update function cannot know whether you’re in a trigger or not. You need a flag, i.e. a boolean, that will be set to true as soon as you enter the trigger and set to false as soon as you exit the trigger (OnTriggerExit).
Then, in the Update method, do not only check for the Input to happen, but also for the boolean variable to be true.

if(Input.GetKeyDown("f") && myBooleanVariable)
{
    // your logic
}