Garry's Mod Wiki


  boolean input.WasMousePressed( number key )


Returns whether a mouse key was initially pressed in the same frame this function was called.

If input.WasMouseDoublePressed returns true, this function will return false.

This function only works in Move hooks, and will detect mouse events even in main menu or when a typing in a text field.


1 number key
The key, see MOUSE enum


1 boolean
True if the mouse key was initially pressed the same frame that this function was called, false otherwise.


Example usage

hook.Add( "CreateMove", "fafawefafwf", function() if ( input.WasMousePressed( MOUSE_LEFT ) ) then print( "Left mouse button was pressed" ) end end )