---
title: "Events: Programs That React to What the User Does"
description: "A program does not have to run from top to bottom. A handler sits waiting for a click, a key press or a collision, and runs only when that thing happens."
canonical: https://lightmysky.com/learn/computing/events-programs-that-react-to-what-the-user-does-mt_HFtGUhZHz4
source: https://lightmysky.com/learn/computing/events-programs-that-react-to-what-the-user-does-mt_HFtGUhZHz4.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Events: Programs That React to What the User Does

A program does not have to run from top to bottom. A handler sits waiting for a click, a key press or a collision, and runs only when that thing happens.

Subject: Computing · Area: Computing Fundamentals · Ages 12 to 13
Page: https://lightmysky.com/learn/computing/events-programs-that-react-to-what-the-user-does-mt_HFtGUhZHz4

## Ready when they can

- Attach one handler to a key press and another to a click in the same program, and say which runs when
- Explain why an event-driven program looks like it is doing nothing until the user acts
- Fix a program where the handler was attached to the wrong object or the wrong event

## Lesson: Programs that wait for you

Some programs do not run from top to bottom. A handler is a small set of instructions that sits waiting for one event, like a click or a key press. It runs only when that event happens.

**Example.** Imagine a game where the left arrow moves your sprite and a click changes its colour. Pressing the key runs the key handler, and clicking runs the click handler. Tapping a button on a page can run code that changes its colour, which tells you it was clicked.

That is why an event program looks like it is doing nothing. It is not stuck, it is listening. Nothing moves until you act.

**Tip.** If the wrong thing happens, check two things. First, is the handler attached to the right object. Second, is it listening for the right event. A handler can also test whether a text field holds a name before it changes a colour. A click handler on the wrong button never fires when you click yours.

**Recap.** Handlers wait for their event, then run, so nothing happens until you click or press.

## Practice

10 questions on this page, each with its working shown.

## Needs first

- [Programming with Loops and Variables](https://lightmysky.com/learn/computing/programming-with-loops-and-variables-mt_9x5zgShXPg)
- [AI in Computer Games](https://lightmysky.com/learn/computing/ai-in-computer-games-mt_fT4G0QloX5)

## Opens up

- [Conditions That Combine: And, Or and Not](https://lightmysky.com/learn/computing/conditions-that-combine-and-or-and-not-mt_ZYdtXQZy5r)
