mouse_check_button

This function will return true if the mouse button being checked is held down or false if it is not.

You supply the mouse button to check from one of the following constants:

Mouse Button Constant
ConstantDescription
mb_leftThe left mouse button
mb_middleThe middle mouse button (this may not be valid for all target platforms)
mb_rightThe right mouse button
mb_side1*Mouse side button 1
mb_side2*Mouse side button 2
mb_anyAny of the mouse buttons
mb_noneNo mouse button

* NOTE The mb_side1 and mb_side2 buttons are only for use on Windows, macOS, Ubuntu and HTML5.

Syntax:

mouse_check_button(numb);

ArgumentTypeDescription
numbMouse Button ConstantWhich mouse button constant to check for.

 

Returns:

Boolean

 

Example:

if mouse_check_button(mb_left)
{
    instance_create_layer(mouse_x, mouse_y, "Effects", obj_Star);
}

The above code will check for the left mouse button and every step that it is held down will create an instance of the object indexed in obj_Star.