# Events: Making Things Happen

- Link: https://thecuriosi.com/lessons/scratch-events/
- Published: 2026-10-31T14:56:34+05:30
- Author: MAHENDRA MANCHIKALAPATI

1. [Courses](https://thecuriosi.com/courses/)
 2. [Coding with Scratch: Make Your First Games](https://thecuriosi.com/courses/scratch-coding-for-kids/)
 3.  Lesson 4 of 10

In real life, things happen because of **events**. When the school bell rings, the
class goes out to play. When you press a doorbell, it rings. In Scratch, **event
blocks** start scripts when something happens. In this lesson you will use events
to control your sprites with the keyboard and mouse.

## Hat blocks

Event blocks have a rounded top, so they are called **hat blocks**. A hat block 
always sits at the **top** of a script. Nothing can go above it.

  |  Event block |  The script runs when… |  
   |  `when green flag clicked` |  the green flag is clicked |  
 |  `when (space) key pressed` |  a chosen key is pressed |  
 |  `when this sprite clicked` |  someone clicks the sprite |  
 |  `when backdrop switches to (backdrop1)` |  the backdrop changes |

## Controlling a sprite with arrow keys

Let’s make a sprite move with the arrow keys. You need **four** small scripts, one
for each arrow.

    ```
    when (right arrow) key pressed
    change x by (10)

    when (left arrow) key pressed
    change x by (-10)

    when (up arrow) key pressed
    change y by (10)

    when (down arrow) key pressed
    change y by (-10)
    ```

Click the stage first, then press the arrow keys. Your sprite moves around!

### Facing the right way

To make the sprite face the way it moves, add `point in direction (90)` to the right-
arrow script and `point in direction (-90)` to the left-arrow script. If the sprite
turns upside down, click the sprite’s **Direction** setting and choose **left/right**
rotation style.

## Clicking on sprites

`when this sprite clicked` is great for buttons and surprises.

### Example

Leo made a drum kit. He added a **Drum** sprite with this script:

    ```
    when this sprite clicked
    start sound (High Tom)
    change size by (10)
    wait (0.2) seconds
    change size by (-10)
    ```

Each time he clicked the drum, it played a sound and “bounced”. He added a cymbal
sprite too, and soon he had a whole band!

## Many scripts at once

A sprite can have **many scripts**, each with its own hat block. They can run at
the same time. One script might control movement with the arrow keys, while another
plays music when the green flag is clicked. This is called **parallel** programming,
and it is how games handle lots of things at once.

### Common bug: keys do nothing

If pressing keys does nothing, click once on the **stage** first. The browser only
sends key presses to Scratch when the stage is selected. Also check that each script
has the right key chosen in its drop-down menu.

## Key takeaways

 * Event blocks, also called hat blocks, start scripts.
 * Hat blocks always go at the top of a script.
 * Use `when key pressed` blocks to control sprites with the keyboard.
 * A sprite can have many scripts running at the same time.

## Practice

Make a sprite that says “Ouch!” when it is clicked, and jumps up 50 and back down
when you press the space key.

Answer: script 1 is `when this sprite clicked`, `say (Ouch!) for (1) seconds`. Script
2 is `when (space) key pressed`, `change y by (50)`, `wait (0.3) seconds`, `change
y by (-50)`.

 [Log in](https://thecuriosi.com/wp-login.php?redirect_to=https%3A%2F%2Fthecuriosi.com%2Flessons%2Fscratch-events%2F)
to mark lessons complete and track your progress.

 [ Previous lesson Moving Sprites with Motion and Coordinates ](https://thecuriosi.com/lessons/scratch-motion-coordinates/)
[ Next lesson Loops: Repeat and Forever ](https://thecuriosi.com/lessons/scratch-loops/)

 [Back to course overview](https://thecuriosi.com/courses/scratch-coding-for-kids/)

Share this
