How do I create a script that makes text appear when the player is close enough to an object and then disappear when the player moves away?

I am making a game that involves finding objects around the environment. So far I made it so that the name of the object appears when the player approaches it, but now I need to make it so that the text disappears once the player has exited the collider. Here is my code for the object; how can I fix it to make this addition?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TextTrigger : MonoBehaviour
{

    public Text keycardText;
    private bool closeEnough = false;


    void Start()
    {
        closeEnough = false;
        keycardText.text = " ";
    }

    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Player")
        {
            closeEnough = true;
            keycardText.text = "Keycard";
        }
    }
}

Thank you!

Have you tried using OnTriggerExit?:

void OnTriggerExit(Collider col)
{
    if (col.tag == "Player")
    {
        closeEnough = false;
        keycardText.text = null;
    }
}

void OnTriggerExit(Collider col)
{
if (col.tag == “Player”)
{
closeEnough = false;
keycardText.text = “”;
}
}

That helps a lot! Is there a way I could also make the text disappear when the player picks up the object?