- Home
- /
- Computational Thinking
- /
- Computational Thinking
- /
- Event
A detectable action or occurrence in a program—such as a user click, key press, mouse movement, or timer expiry—that the program can respond to by executing a predefined event handler function. Events are how interactive programs—games, apps, websites—respond to user actions in real time.
Definition
A detectable action or occurrence in a program—such as a user click, key press, mouse movement, or timer expiry—that the program can respond to by executing a predefined event handler function.
💡 Intuition
Something happens (click, keypress, timer) and the program reacts.
🎯 Core Idea
Event-driven programs wait for things to happen rather than following a fixed sequence.
Example
🌟 Why It Matters
Events are how interactive programs—games, apps, websites—respond to user actions in real time. Every button you click, every key you press, and every touch on a screen fires an event that software listens for and responds to.
💭 Hint When Stuck
When working with events, first identify which actions your program needs to respond to (clicks, keypresses, timers). Then write an event handler function for each event type. Finally, register (attach) the handler so the system knows to call it when the event occurs.
Formal View
Related Concepts
🚧 Common Stuck Point
Events can occur in any order—the program must handle any sequence.
⚠️ Common Mistakes
- Forgetting to register the event handler, so the event fires but nothing happens
- Assuming events occur in a predictable order when users can interact in any sequence
- Writing event handlers that take too long to execute, making the program feel unresponsive
Frequently Asked Questions
What is Event in CS Thinking?
A detectable action or occurrence in a program—such as a user click, key press, mouse movement, or timer expiry—that the program can respond to by executing a predefined event handler function.
When do you use Event?
When working with events, first identify which actions your program needs to respond to (clicks, keypresses, timers). Then write an event handler function for each event type. Finally, register (attach) the handler so the system knows to call it when the event occurs.
What do students usually get wrong about Event?
Events can occur in any order—the program must handle any sequence.
Prerequisites
Next Steps
How Event Connects to Other Ideas
To understand event, you should first be comfortable with function. Once you have a solid grasp of event, you can move on to event handler and user interface.
💻 Animated Visualization Animated
Different events trigger different responses