How can i enable and disable a void function on the update function?

This is what i came up whit so far

public GameObject onOff;

// Use this for initialization
void Start()
{
    onOff.SetActive(false);
}

// Update is called once per s
void Update()
{
    if (Input.GetKeyDown(KeyCode.E))
        {
        EnterNumber();
        onOff.SetActive(true);
        Cursor.visible = true;
        }
    else if (Input.GetKeyUp(KeyCode.Q))
    {
        onOff.SetActive(false);
        Cursor.visible = false;
    }

}

private void EnterNumber()
{
    Debug.Log("function activated");

}

}

Good day @DytrooydeDev

I think you need to watch some tutorial about basic scripting… A function is not “activated” A function is something that you execute, something that you can call to make things,

With this code, each frame detects if “E” has been clicked or if “Q” has been clicked.

when E is clicked, you run the EnterNumber() method, activate the gameobject onOff and make the cursor visible.

As I said, i strongly recommend you to spend 2-3 hours waching basic tutorials about Scripting and about Unity before continue. You will appreciate it.

Good luck!
Bye!