image

IN REAL LIFE, events can be anything that happens, such as a birthday party, parade, or a snowstorm. In programming, events are things that happen within your program. Scratch has a special collection of blocks for you to use to make things happen in your programs: the Events Block Palette. You’ve already seen one such block—the when green flag clicked block. In this adventure, you learn about the other Event blocks.

Understanding the Role of Events

Until now, all your Scratch programming adventures have used forever loops to repeatedly check whether an event such as a mouse click or a key press is happening. This method works, but it makes it difficult to keep your code and your Scripts Areas organized.

In this adventure, you learn to use Event blocks to detect things that happen within your program.

There are eight blocks in the Events Block Palette. Six of the Event blocks are hat blocks. The other two are stack blocks. Event blocks are color-coded brown.

Get Adventures in Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.