how to make a menu open and close with the same button

my code looks like this:
void Update ()
{

	if (Input.GetKeyDown(KeyCode.Tab) && computerOn == false)
	{
		SuperStore.SetActive(true);
		computerOn = true;
	}

	if (Input.GetKeyDown(KeyCode.Tab) && computerOn == true)
	{
		SuperStore.SetActive(false);
		computerOn = false;
	}
}

what i think currently happens is that when i press tab it opens and closes the menu really fast but i have no idea how to fix it please help.

btw SuperStore is the menu.

What you need to do is make it an ELSE if

Because now you’re excuting your first if, setting you bool to true, and then executing the other if thats not what you want.

 if (Input.GetKeyDown(KeyCode.Tab) && computerOn == false)
 {
     SuperStore.SetActive(true);
     computerOn = true;
 }
 else if (Input.GetKeyDown(KeyCode.Tab) && computerOn == true)
 {
     SuperStore.SetActive(false);
     computerOn = false;
 }

But you can write it much shorter.

if (Input.GetKeyDown(KeyCode.Tab)) 
{
    computerOn = !computerOn;
    SuperStore.SetActive(computerOn);
}

Okay, so try this

Bool MenuIsUp = false; 

if (Input.GetKeyDown(KeyCode.Tab) )
     {


if (MenuIsUp == false)

{
         SuperStore.SetActive(true);
MenuIsUp = true;
         
  } else {


SuperStore.SetActive(false);
MenuIsUp=false;

}

I am unsure if this would work but it is the first thing that popped into my head when reading your issue

You could also do like diss
if (Input.GetKeyDown(KeyCode.Tab)){ SuperStore.SetActive(!SuperStore.activeSelf); computerOn = SuperStore.activeSelf; }

much less code and way cleaner in my opinion.