Differences

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

Link to this comparison view

Both sides previous revision Previous revision
p5js-interaction [2024/02/22 00:31] renickp5js-interaction [2024/03/13 07:47] (current) renick
Line 107: Line 107:
 ===== doing something while a key is down ===== ===== 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:+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. In this case, we use the key 'b' (represented by the keycode 66) to change the rect under the mouse to the color red:
  
 <HTML> <HTML>
Line 114: Line 114:
  
 Read more about the keyIsDown function here: https://p5js.org/reference/#/p5/keyIsDown Read more about the keyIsDown function here: https://p5js.org/reference/#/p5/keyIsDown
 +
 +You can find all of the key codes here: https://www.toptal.com/developers/keycode
  
 ===== more about mouse and keyboard in p5js ===== ===== more about mouse and keyboard in p5js =====
  • p5js-interaction.txt
  • Last modified: 2 months ago
  • by renick