Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
p5js-interaction [2024/02/21 23:46] renickp5js-interaction [2024/02/22 00:29] renick
Line 104: Line 104:
 <iframe src="https://editor.p5js.org/renick/full/jdci35yJq" width=99% height=800></iframe> <iframe src="https://editor.p5js.org/renick/full/jdci35yJq" width=99% height=800></iframe>
 </HTML> </HTML>
 +
 +===== doing something while a key is down =====
 +
 +Above, we stored key presses. We can also do something based on whether a certain key is pressed. The keyIsDown function returns either 'true' or 'false', so we can use that in an if-statement to control the behaviour of our program:
 +
 +<HTML>
 +<iframe src="https://editor.p5js.org/renick/full/SiRrljdNQ" width=99% height=800></iframe>
 +</HTML>
 +
 +Read more about the keyIsDown function here: https://p5js.org/reference/#/p5/keyIsDown
 +
 +===== more about mouse and keyboard in p5js =====
 +
 +For more on mouse and keyboard interaction in p5js, see the 'mouse' and 'keyboard' section in the reference here: https://p5js.org/reference/
  
 ===== using mouse and keyboard events outside of p5js ===== ===== using mouse and keyboard events outside of p5js =====
  
 +All of these are done with the functions provided by p5js. There is a whole set of keyboard and mouse event handlers built into your browser. You can find more information on them here:
 +
 +keyboard events: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
  
 +mouse events: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
  • p5js-interaction.txt
  • Last modified: 4 months ago
  • by renick