If Mouse Pressed


With this action you can poll the mouse to see if any button is currently being pressed. The action will return true every step that the mouse button is being pressed (and held) down, or false otherwise, although if you click the not modifier you can then check to see if the mouse button is not being pressed, ie: the action will return true while no button is pressed and false if there is. If you only need to check for a single mouse press then use the action if mouse_down.

Note that to add actions into the "if" block, they should be dropped to the side of the action, as shown in the image below: If Add Actions

These actions will now be run if the "if" evaluates to true, while any actions dropped elsewhere will be performed after the "if" block.

Action Syntax:

Mouse Pressed Syntax


Argument Description
Mouse Button The name of the mouse button to check (left, middle, right).
Not Negate the check (true becomes false and vice versa)


Mouse Pressed Example
The above action block code polls the mouse button state every step and if it is being held down it checks for the initial mouse down press. If the check is on the initial down press, then a sound is played, then while the button is down, the sprite blending is changed to red. If the mouse is not being held down, a check is done on the mouse release to reset the blending colour to white.