inactive after active with press key unity

Code Example - inactive after active with press key unity

                
                        if (Input.GetKeyDown(KeyCode.Escape))
{
    yourObject.SetActive(!yourObject.activeSelf);
}