Make your sketches come alive and react to YOU.
🎯 Goals for This Session
By the end of this session, you will be able to:
- Make your p5.js sketch react when you click the mouse
- Make your sketch respond when you press keys
- Build small interactive tools like a paintbrush or a creature that follows your mouse
This is where your code starts listening to you!
1. What Is Interactivity?
Interactivity = your sketch responds to what you do.
Examples:
- Click to change colors
- Move the mouse to move objects
- Press keys to trigger effects
- Make characters jump, grow, explode, dance, etc.
In p5.js, interactivity happens because of built-in variables and functions such as:
✔ mouseX
Where your mouse is (left–right)