Can't toggle bool variable

I want to toggle bool variable isPauseEnebled, but when I press Escape key, it works only one time, even if I press Escape a lot of times.

bool isPauseEnabled;

void Start()
{
	isPauseEnabled = false;
}

void Update ()
{
	if (Input.GetKeyDown (KeyCode.Escape))
	{
		Debug.Log ("123"); // Why it works only one time?
		if(!isPauseEnabled) // Work one time too
		{
			isPauseEnabled = true;
		}
		else // Don't work
		{
			isPauseEnabled = false;
		}
	}
}

I just copy-pasted your script into a new file on my own machine and tested it. There is nothing wrong with it, it works fine.

I made isPauseEnabled public just as a test so I could see it in the editor, and watched the checkmark appear and disappear in the inspector. It gets toggled correctly.

If the “123” text only appears once, it could be because you have “Collapse” enabled in the console.

I did notice, though, that it does not work if the Console window or the Scene view currently has focus. You have to click the Game View to give that window focus, or it won’t receive keyboard events.

By the way, there is a more compact way to toggle booleans. Just set it to its own negation:

void Update()
{
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        Debug.Log("123"); // Why it works only one time?
        isPauseEnabled = !isPauseEnabled;
    }
}