mouseButton
A String system variable that contains the value of the last mouse button pressed.
The mouseButton variable is either LEFT, RIGHT, or CENTER, depending on which button was pressed last.
Note that the mouse must be pressed on the window to be detected and reported.
Examples

-- Click on the window to detect the mouseButton
function setup()
size(100, 100)
describe(
'A gray square. Black text appears and changes to either "left" or "right" when the user clicks a mouse button on the window.'
)
end
function draw()
background(200)
fill(0)
-- Style the text.
textAlign(CENTER)
textSize(16)
-- Display the mouse button.
text(mouseButton, 50, 50)
end

function setup()
size(100, 100)
describe(
"A gray square. Different shapes appear at its center depending on the mouse button that's clicked."
)
end
function draw()
background(200)
if mouseIsPressed == true then
if mouseButton == LEFT then
circle(50, 50, 50)
end
if mouseButton == RIGHT then
square(25, 25, 50)
end
if mouseButton == CENTER then
triangle(23, 75, 50, 20, 78, 75)
end
end
end
Syntax
mouseButton
Returns
STRING: Either, LEFT ('left'), CENTER ('center') or RIGHT ('right')