How do I attach Right Click to an EventSystem listener?

I’m trying to attach both a left click function call and a right click function call to an EventSystem listener. I seem to be successful with the left click but not the right click.

I’m currently trying to run a variable (int) that is stored from Update when you left or right click, but the EventSystem doesn’t even bother registering right clicks, so the listener is never run for right clicks, is there some way to force the EventSystem to pick up on right clicks?

I was hoping to avoid running update every frame just to check for a right click as I only want to check for this right click when the UI is open (Right click is used for other things related to game play while the UI is closed).

public int currentMouseInput = -1;

public Button tempButton = new Button();


void Start() {
    tempButton.onClick.AddListener(() =>
    {
        if (currentMouseInput == 0)
        {
            print("Left Click Working");
        }
        else if (currentMouseInput == 1)
        {
            print("Right Click Working");
        }
    });
}

void Update() {
    if (Input.GetMouseButtonDown(0)) 
    {
        currentMouseInput = 0;
    }
    else if (Input.GetMouseButtonDown(1))
    {
        currentMouseInput = 1;
    }
}

AFAIK there is no default onClick event to receive right click on a button. The onClick is for left click only. But you can create one using OnPointerDown from IPointerDownHandler and OnPointerUp from IPointerUpHandler interfaces.