O'Reilly logo

Learn JavaScript with p5.js: Coding for Visual Learners by Engin Arslan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Engin Arslan 2018
Engin ArslanLearn JavaScript with p5.jshttps://doi.org/10.1007/978-1-4842-3426-6_11

11. Events

Engin Arslan
(1)
Toronto, Ontario, Canada
 
In Chapter 6, we learned about a p5.js variable called mouseIsPressed, which assumes the value to be true while the mouse is being pressed and false for all other instances.
We also learned that this is not a great way of capturing user input as the execution speed of the draw function can make it hard to get this variable updated in a reliable way. In this chapter we’ll review other ways of handling user input inside p5.js, namely, the events, which solve this problem. Using events, we can capture the user input outside the draw function loop.
There are numerous event functions in p5.js that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required