p5.js | Mouse | mouseButton
The mouseButton variable in p5.js is used to get automatically which kind of key is pressed on mouse. The value of the system variable mouseButton is either LEFT, RIGHT, or CENTER depending on which button was pressed last.
Below programs illustrate the mouseButton variable in p5.js:
Example 1: This example uses mouseButton variable to detect the mouse button.
Example 2: This example uses mouseButton variable to detect the mouse button.