Submodule 17.1: Events

  • Introduction to p5.js events
  • mouseX and mouseY
  • mouseClicked()
  • mouseIsPressed

Introduction to p5.js events

P5.js events have built-in events that enable you to apply interactivity in your canvas.

Using these functions you can apply changes to your sketch/animation when the user does something.

For example, you can change the color of a shape when the user clicks on it.

Let's see some of these events