Pause Menu open/close on key

I’m trying to get my pause menu to open and close when the player presses the “p” key. The buttons on the pause menu work to take you to the main menu and quit the game, but for some reason, the menu won’t activate/deactivate once the “p” key is pressed. At first I created the menu in its own scene, but I’ve added it to my level to see if it would make a difference (it didn’t)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PauseMenu : MonoBehaviour
{
    
    public static bool GameIsPaused = false;

    public GameObject PauseMenuBehavior;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.P))
        {
            if (GameIsPaused)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }
    }
    public void Resume()
    {
        PauseMenuBehavior.SetActive(false);
        Time.timeScale = 1f;
        GameIsPaused = false;
    }
    public void MainMenu()
    {
        Time.timeScale = 1f;
        SceneManager.LoadScene("Main_Menu");
    }
    void Pause()
    {
        PauseMenuBehavior.SetActive(true);
        Time.timeScale = 0f;
        GameIsPaused = true;
    }
    public void QuitGame()
    {
        Application.Quit();
        Debug.Log("Quitting game...");
    }
}

I used your exact code. It’s working perfectly for me. The code looks the same as the Brakeys tutorial (PAUSE MENU in Unity - YouTube) but I think maybe the buttons on your pause menu are overriding your P key input. If you have buttons on your pause menu try setting the Navigation option on the button to None and test. I think you will find this is the problem. The Navigation option does things like accepting Spacebar to click a button. Image attached of where to set this option.

120347-button.png