🔔 Event
4th Grade 💻 Coding
An event is something that happens while a program is running, like a button click, a key press, a tap on the screen, or a certain amount of time passing. The program can respond to it.
An event-driven program doesn’t just run from start to finish. It waits. When an event happens, it runs the code that goes with that event. That’s how games, websites and apps work: every button, every key and every swipe of a finger is an event that someone wrote a response for.
In Scratch, event blocks are yellow and have a rounded “hat” on top: “when green flag clicked,” “when space key pressed,” “when this sprite clicked.” In JavaScript, you can decide what will happen on a button’s click event.
For example
- A doorbell responds to the “press” event by ringing.
- In a game, the event “right arrow pressed” makes the character move right.
- Time can be an event too: an alarm clock responds to the event “it’s 7:00” by ringing.
- On a website, scrolling to the bottom of the page is an event that loads more content.
📌 Remember: An event = “Something happened!” The program waits and responds.
Quick quiz
What is an event?
What color are event blocks in Scratch?
Which of these is an event?