Make button ignore cursor movement

How do I make button ignore cursor movement, so it can be held down even when cursor is moving?

When the button is pressed set a bool to true. When the mouse button is released Input.GetMouseButtonUp(0)
set that bool to false. Now you just check that bool if you want to know if the user is pressing the button.