Scratch Event Blocks Tutorial: A Complete Guide to Event Driven Programming for Beginners
Introduction – Scratch Event Blocks
Welcome to this tutorial on Scratch Event Blocks—your introduction to event-driven programming, where creativity meets interactivity! Whether you're new to coding or teaching kids how to code, you'll discover just how powerful Scratch's event blocks can be in bringing projects to life. From click-triggered animations to keyboard-controlled actions and sprite-to-sprite conversations, these blocks form the foundation for dynamic storytelling and engaging, user-driven experiences.
Check out the full video tutorial: Scratch Event Blocks Full Tutorial | With Fun Animations & Examples | Kodex Academy
This guide will walk you through the essentials of:
- When Green Flag Clicked – kickstart your projects
- When Key Pressed – make sprites move with controls
- When This Sprite Clicked – create interactive characters
- When Backdrop Switches To… – bring scene changes to life
- When Loudness Is Greater Than… – add voice-responsive features
- Broadcast and When I Receive – enable sprite communication and synchronized action
By watching the video, you'll see these event blocks in action—play, pause, and explore each section at your own pace. Then dive into our step-by-step walkthrough to master Scratch's event-driven programming and start creating your own interactive animations today.
What Are Event Blocks in Scratch?
Event blocks in Scratch are special command blocks that control when and how your scripts start. They are part of the Events category in Scratch and form the core of event-driven programming, where scripts respond to specific actions or inputs—like mouse clicks, key presses, sound detection, or messages from other sprites.
Why Are Event Blocks Important?
Event blocks allow you to:
- Start scripts when the green flag is clicked
- React to user inputs like keyboard keys or mouse clicks
- Communicate between sprites using broadcast messages
- Trigger animations or actions based on conditions like loudness or backdrop changes
These blocks make your Scratch projects interactive, responsive, and fun to use!
Common Event Blocks in Scratch:
Here are a few of the most used event blocks:
| Event Block | Description |
|---|---|
when green flag clicked |
Starts the script when the green flag is clicked (most common starter block) |
when [key] key pressed |
Runs the script when a specific keyboard key is pressed |
when this sprite clicked |
Triggers an action when a user clicks the sprite |
when I receive [message] |
Starts a script in response to a broadcast message |
broadcast [message] |
Sends a message to trigger scripts in other sprites |
broadcast [message] and wait |
Sends a message and waits until all receiving scripts are done |
when backdrop switches to [backdrop] |
Runs the script when the stage backdrop changes |
when loudness > [value] |
Starts a script when the microphone detects a loud sound above a certain threshold |
Watch this in action in the full Scratch Event Blocks Tutorial
Exploring Key Scratch Event Blocks (with Examples)
Scratch Event Blocks are essential for creating interactive and responsive projects. They allow your program to respond to user actions like clicking, key pressing, or receiving messages. Let's explore the most important ones with practical examples to help you understand their role in event-driven programming.
a. When Green Flag Clicked
The most commonly used event block. It triggers your script when the green flag is clicked.
Use Case: Start an animation or game when the project begins.
say "Let's start!" for 2 seconds
play sound [pop v]
Perfect for starting games, stories, or animations.
b. When This Sprite Clicked
This block starts a script when the user clicks on a sprite.
Use Case: Create interactive elements like buttons or characters that react when clicked.
change color effect by 25
say "Hey! You clicked me!" for 2 seconds
Perfect for clickable characters or objects in games and learning apps.
c. When [Key] Key Pressed
Triggers an action when a specific key on the keyboard is pressed.
Use Case: Control a character in a game using arrow keys or specific letters.
change x by 10
Perfect for making platformers or movement-based games.
d. When Loudness > [Value]
Uses your microphone to detect loud sounds. Great for sound-based interactivity!
Use Case: Make your sprite react when a loud sound is detected.
say "Whoa! That was loud!" for 2 seconds
Perfect for fun experiments, accessibility features, or sound-sensitive games.
e. When Backdrop Switches to [Backdrop]
Triggers a script when the backdrop (background) of the stage changes.
Use Case: Change scenes and control what happens next in a story.
say "Good night!" for 2 seconds
Perfect for storytelling projects and scene transitions.
f. When Timer > [Value]
This block triggers when the timer reaches a specific value. Useful for time-based events.
Use Case: Create timed challenges or schedule events in your project.
say "Time's up!" for 2 seconds
stop all
Perfect for timed games, countdowns, or scheduled animations.
g. When Video Motion > [Value]
This block detects motion in the video feed from your camera. Perfect for motion-controlled games!
Use Case: Make your sprite react to movement in front of the camera.
change size by 10
play sound [boing v]
Perfect for interactive installations, motion games, or accessibility features.
h. Broadcast [Message] & When I Receive [Message]
These two blocks work together to enable sprite communication.
broadcast [message]sends a signal to all sprites.when I receive [message]listens for that signal and triggers a script.
Use Case: Create a conversation or trigger events across multiple sprites.
when green flag clicked
say "Hello, Fox!" for 2 seconds
broadcast [Hello, Cat!]
// Fox sprite
when I receive [Hello, Cat!]
say "Hello, dear cat!" for 2 seconds
Perfect for syncing animations, conversations, or events across sprites.
i. Broadcast and Wait
Same as the regular broadcast, but waits until the receiving scripts are finished before continuing.
Use Case: Ensure a message is fully handled before the next action.
broadcast [Start Scene] and wait
say "Scene complete!" for 2 seconds
Perfect for sequencing actions, story flow, or ensuring task completion.
Enhancements & Advanced Features with Example Code
1. Voice-Activated Sprite Animation
forever
if <(loudness) > (20)> then
broadcast [loudEvent v]
end
end
when I receive [loudEvent v]
change color effect by (25)
play sound [pop v]
2. Sequential Dialogue with Broadcast and Wait
broadcast [dialog1 v] and wait
broadcast [dialog2 v] and wait
when I receive [dialog1 v]
say [Hello, I am Cat!] for (2) secs
when I receive [dialog2 v]
say [Nice to meet you, Fox!] for (2) secs
3. Targeted Broadcasts (Specific Sprite Only)
Using variables to control message targets.
broadcast [init v]
// Sprite A
when I receive [init v]
set [MyID v] to [A]
// Sprite B
when I receive [init v]
set [MyID v] to [B]
// Stage sends
set [_receiver v] to [B]
broadcast [flipMessage v] and wait
// Sprite B receives
when I receive [flipMessage v]
if <(_receiver) = (MyID)> then
turn cw 180 degrees
end
4. Drawing Tool Example (Event Blocks + Pen)
clear
when this sprite clicked
pen down
forever
if
point towards [mouse-pointer v]
move (10) steps
else
pen up
end
end
when [space v] key pressed
clear
Real Project Example: Interactive Animation
Let's put everything together and create a fun interactive animation that demonstrates multiple event blocks working together. We'll create a "Magic Garden" where clicking on different flowers triggers different animations and sounds.
Project Setup
- Create a new Scratch project
- Add flower sprites (or draw your own)
- Add different backdrops for day/night
- Import sounds for each flower
Step-by-Step Code
1. Stage Script (Controls the Scene)
when green flag clicked
switch backdrop to [Garden Day v]
set [timer v] to [0]
broadcast [start garden v]
// Change to night after 30 seconds
when timer > 30
switch backdrop to [Garden Night v]
broadcast [night time v]
// Reset to day when space is pressed
when [space v] key pressed
switch backdrop to [Garden Day v]
set [timer v] to [0]
broadcast [day time v]
2. Flower Sprite Scripts (Rose)
when I receive [start garden v]
go to x: (-100) y: (-50)
set size to (80) %
// React when clicked
when this sprite clicked
play sound [Rose Sound v]
repeat (10)
change size by (5)
wait (0.1) secs
end
repeat (10)
change size by (-5)
wait (0.1) secs
end
broadcast [rose bloomed v]
// React to night time
when I receive [night time v]
set [ghost v] effect to (50)
// React to day time
when I receive [day time v]
clear graphic effects
3. Flower Sprite Scripts (Sunflower)
when I receive [start garden v]
go to x: (0) y: (-30)
set size to (100) %
// React when clicked
when this sprite clicked
play sound [Sunflower Sound v]
repeat (15)
turn cw (24) degrees
wait (0.1) secs
end
broadcast [sunflower danced v]
// Special reaction to loud sounds
when loudness > 50
say "Whoa! That was loud!" for 2 seconds
turn cw (360) degrees
4. Flower Sprite Scripts (Tulip)
when I receive [start garden v]
go to x: (100) y: (-70)
set size to (60) %
// React when clicked
when this sprite clicked
play sound [Tulip Sound v]
glide (1) secs to x: (100) y: (50)
wait (1) secs
glide (1) secs to x: (100) y: (-70)
broadcast [tulip jumped v]
// React to other flowers blooming
when I receive [rose bloomed v]
say "Pretty rose!" for 2 seconds
when I receive [sunflower danced v]
say "Nice dance!" for 2 seconds
What You'll Learn from This Project
- Event Coordination: How multiple event blocks work together
- Sprite Communication: Using broadcast messages between sprites
- Backdrop Events: Responding to scene changes
- Timer Events: Time-based scene transitions
- Sound Events: Reacting to audio input
- Interactive Design: Creating engaging user experiences
Enhancement Ideas
- Add more flowers with unique animations
- Include weather effects triggered by timer events
- Create a scoring system for user interactions
- Add video motion detection for "wind" effects
- Include keyboard controls for special actions
This interactive garden project demonstrates the power of combining multiple event blocks to create rich, responsive experiences. Each flower reacts differently to user input while communicating with other elements in the scene.
Conclusion: Unlocking the Power of Scratch Event Blocks
Scratch Event Blocks are the foundation of interactive and event-driven programming in the Scratch environment. Whether you're building animations, storytelling projects, or full-fledged games, mastering these blocks enables you to control how and when your scripts run—from simple actions like "When Green Flag Clicked" to more complex sprite interactions using Broadcast and Broadcast and Wait.
Through this tutorial, you've explored:
- Core event blocks and their usage
- Real project examples with code
- Creative enhancements to elevate your projects
- How communication between sprites drives interactivity
By combining these blocks creatively, young coders can bring their ideas to life with precision and logic. If you're new to Scratch, this is your gateway to creating responsive, engaging, and intelligent projects.
Call to Action
- Don't forget to check out the full video tutorial by Kodex Academy here: Scratch Event Blocks Full Tutorial | With Fun Animations & Examples | Kodex Academy
- Like, comment & share the video
- Visit kodexacademy.com
- Subscribe to the Kodex Academy YouTube channel for deeper Scratch content.
Happy coding with Kodex Academy! 🚀
Learn More with Kodex Academy
At Kodex Academy, we're passionate about helping students learn coding in creative ways. This project teaches more than Scratch—it empowers young minds to build tools that work in the real world.
Explore more:
Stay updated with new content, free tutorials, and coding challenges!
- 🌐 Website: https://kodexacademy.com/
- 💬 WhatsApp Channel: Join Now
- 📼 LinkedIn: Kodex Academy
- 📸 Instagram: @kodex_academy
- 🐦 Twitter: @Kodex_Academy
- 📢 Telegram: Join Our Channel
- 🎗️ Patreon: patreon.com/KodexAcademy