Pausing the game. Problem

I made a code when you press esc it will pause but I have to press resume 5 times instead of one.

  if (Input.GetKeyDown(KeyCode.Escape))
    {
        if (GameisPaused)
        {
            Resume();
        }
        else
        {
            Pause();

        }
    }
}
if (Input.GetKeyDown(KeyCode.Escape) && !boolname)
public void Resume()
{
    SceneManager.UnloadSceneAsync("Game Option");
    Time.timeScale = 1f;
}
void Pause()
{
    Time.timeScale = 0f;
    SceneManager.LoadScene("Game Option", LoadSceneMode.Additive);
}

What is this line doing?

if (Input.GetKeyDown(KeyCode.Escape) && !boolname)

Also, the variable GameisPaused does not change when you pause and resume the game.