Event Listeners
and Timers
Flashcards
"flip!"

When adding an event listener as an element attribute, what needs to be put before the listener action?
on_____, Ex
onclick
How do you add an event listener without changing any html attributes?
element.
addEventListener
("event", function)
When using a keyboard listener, how do you tell what key was pressed?
have a function input (in this case called event), then use
event.key
How do you tell what mouse button was used in a mouse event?
event.button
How do you delay a function from happening immediately?
setTimeout
(function, delay)
How do you repeatedly call a function with a delay inbetween each iteration?
setInerval
(function, delay)
How does the
requestAnimation-
Frame
function work?
It waits untill the GPU/processor is in low use and then calls the function. This is useful for animations since it usually will delay the call by 1/60s.
Does
requestAnimation-
Frame
repeatedly call the function?
No, it should be put inside the function that it calls if you want to make a loop.

Back to Assignments, or the Original Flashcards(done with only html and css!).