If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Course: Unlisted resources area > Unit 2

Lesson 1: ProcessingJS documentation

mouseClicked()

If you define a function called mouseClicked in your code, then that function will get called every time the user clicks the mouse.
This function is useful for implementing things like clickable buttons. You can just check whether the mouseX and mouseY are within certain coordinates when the mouse is released, and if so, consider it a "click."
You might also be interested in mouseReleased, mousePressed, or mouseMoved depending on what you're trying to implement.

Want to join the conversation?

No posts yet.