PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

GetMouseButtonsPressed

This function returns an array of InputObject|InputObjects corresponding to the mouse buttons currently being pressed down.

Mouse buttons that are tracked by this function include:

Name Description
MouseButton1 The left mouse button.
MouseButton2 The right mouse button.
MouseButton3 The middle mouse button.

If the user is not pressing any mouse button down when the function is called, it will return an empty array.

As UserInputService is client-side only, this function can only be used in a LocalScript.

Returns

Return Type Summary

An array of InputObject|InputObjects corresponding to the mouse buttons currently being currently held down


Code Samples


Check which MouseButtons are Pressed

This example checks if the user pressed MouseButton1, MouseButton2, or both mouse buttons on UserInputService/InputBegan|InputBegan.

The example can be extended to behave differently depending on which mouse buttons are pressed.