Events: when something happens

Knowledge Videos

Short animated explainers, organised by subject.

Events: when something happens

An event is something that happens, like a click or a key press, and an event handler is the script that runs when it does. Shown with Scratch blocks.

Transcript

An event is something that happens: a mouse click, a key press, or a tap on the screen. A program can wait for events, and then react.

A script that starts with an event block is called an event handler. Here, when the green flag is clicked, the handler runs: the cat moves, and says hello.

Different events start different handlers. Press the space key, and the cat jumps. Click the cat, and it says hi.

The program just waits and listens, like a doorbell. Nothing happens until someone presses it.

Remember: an event is something that happens, and an event handler is the script that runs when it does.

More in this series