keyPressed()
Example
Syntax
Description
Like draw() and setup() functions, this function is a built-in function that we override. That is, it knows when to run, but it doesn't know what do? That's why in the syntax, we just seem to define it, but not call it later.
So, this function runs when a key is pressed (once it's hit, regardless if you hold it or release it later).
Built-in variables like keyCode
and key
can be used to know which key was pressed.
Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!
We'd love to hear your Feedback/Comments here.
Last updated