Open In App
Related Articles

p5.js Events Complete Reference

Improve Article
Save Article
Like Article

The p5.js events used to provide a dynamic interface to a webpage. These events are hooked to elements in the Document Object Model(DOM).



keyIsPressedIt is true if any key is pressed and false if no keys are pressed.
keyIt always contains the value of the key which is recently pressed.
keyCodeIt always contains the key code of the key that is recently pressed.
keyPressed()It is invoked whenever a key is pressed.
keyReleased()It is invoked whenever a key is called every time when a key is pressed.
keyTyped()It is invoked every time when a key is pressed, except for action keys.
keyIsDown()It checks the key’s current status that key is down.



mouseMoved()It is called every time the mouse moves.
mouseDragged()It is used to check the mouse drags.
mousePressed()It works when mouse clicked on the document.
mouseReleased()It works when mouse button released.
mouseClicked()It works when mouse button pressed and released.
doubleClicked()It is invoked whenever a mouse causes a dblclick event.
mouseWheel()It is invoked whenever a mouse causes a vertical mouse wheel event.



touchStarted()It is called once after every time a touch is registered.
touchEnded()It is called when a touch ends.
Last Updated : 18 Aug, 2023
Like Article
Save Article
Similar Reads
Related Tutorials