Events Inside Computer Programs You have seen events in the real world — smoke alarms, automatic doors, phone notifications. Now let us look at them inside the programmes you use every day. The Programme That Waits Most programmes do not run from top to bottom and then stop. They launch — and then they wait . They wait for something to happen. When you open a music app, it does not immediately start playing something. It opens and waits: for you to tap a song, for you to search, for you to tap shuffle. The entire programme is waiting for an event. When you open a game, it waits for you to press a key. The moment you press a key — an event — the character moves. When you open a website, it loads — and then waits for you to click a link, fill in a form, scroll down. Events, all of them. This style of programming — where the programme launches and then waits for events — is called event-driven programming . Almost all the apps and websites you use every day are built this way. The Event Listener The way a programme waits for an event is by setting up an event listener . An event listener is like a guard standing at a door. The guard does not do anything most of the time. They just watch. The moment someone comes through the door (the event), the guard acts (the response). In programming: Set up the listener: "Watch for this specific event " Define the response: "When it happens, run these specific commands " Wait: The programme does nothing until the event occurs Event fires: The programme runs the response commands Return to waiting: Ready for the next event Events Inside a Music App Let us map out the events in a music app: Event What Triggers It Response --- --- --- User taps a song title Tap on the song row Start playing the selected song User taps the pause button Tap on the pause icon Stop playback, update button to "play" icon User taps the next button Tap on next icon Stop current song, start next song in the list User adjusts the volume slider Dragging the slider Change playback volume to match slider position Song reaches the end Playback timer hits end of track Start playing the next song automatically App goes to background User presses home button Continue audio, show notification in status bar The entire app is a collection of event listeners and their responses. No event — no action. Events Inside a Simple Game Think of a side-scrolling game where a character can jump: Event Trigger Response --- --- --- Player presses the space bar Key press detected Character jumps upward Character reaches the ground Position equals floor level Stop jump movement Character touches an enemy Collision detected Reduce health by 1 Health reaches zero Health value equals 0 Show "Game Over" screen Player presses Enter on Game Over screen Key press at specific moment Restart the game The game loop runs constantly — but most of the interesting things happen because of events. The player pressing a key. A collision occurring. A value reaching a threshold. Timer Events Not all events come from users. Some events are triggered by time. Every 30 seconds: A traffic signal changes phase Every 1 second: A countdown timer updates the display Every 60 minutes: A news website automatically refreshes its top stories At 11:59 PM (midnight): A special new year message appears These are timer events — the trigger is the clock or a timer reaching a certain point. The programme is listening for a specific moment in time, not a user action. Multiple Listeners, One Programme A real programme has many event listeners running at the same time. The music app is not just listening for "play button tapped" — it is listening for dozens of things simultaneously. This is fine. Each listener is independent — it watches for its one specific event and does its one specific response. They do not interfere with each other. The whole programme is like an orchestra: many musicians, each watching the conductor for their specific cue, each ready to play when their moment comes. ✅ Summary Most computer programmes are event-driven — they launch, then wait for events to occur. An event listener is set up for each event a programme cares about: it watches for the event, and when it occurs, runs the matching commands. Events inside programmes include user actions (taps, clicks, key presses), timer events (at a specific time, or after a certain duration), and system events (a file finishing loading, a network message arriving). A real programme has many event listeners running simultaneously, each responding independently to its specific event. Coming up next: Putting It All Together — a complete event chain from trigger to decomposed response, and a peek at what the next series covers.