The mouseClicked() function in p5.js works when mouse button pressed and released. The browsers may contain different default behaviors attached to various mouse events. To prevent the default behavior for this event, add “return false” to the end of the method.
Below programs illustrate the mouseClicked() function in p5.js:
Example 1: This example illustrates the mouseClicked() function.
- p5.js | Mouse | mouseMoved() Function
- p5.js | Mouse | mouseDragged() Function
- p5.js | Mouse | mousePressed() Function
- p5.js | Mouse | pmouseX
- p5.js | Mouse | mouseReleased()
- p5.js | Mouse | mouseIsPressed
- p5.js | Mouse | winmouseY
- p5.js | Mouse | mouseY
- p5.js | Mouse | mouseX
- p5.js | Mouse | mouseButton
- p5.js | Mouse | pmouseY
- p5.js | Mouse | winmouseX
- How to reverse an animation on mouse out after hover?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.