A useful event model: trigger, surface, logic and result
Before writing code, define the interaction as a clear rule.
A good sentence is: when X happens on Y, run Z and update W. That structure keeps event code readable even as the interface grows.
Not every event expresses the same intention. `input` is continuous feedback, while `change` and `submit` usually mean the user has finished a step.
Trigger
What happens exactly.
- click
- submit
- keydown
Surface
Where you listen.
- button
- form
- delegated container
Logic
What your code decides.
- validate
- toggle
- route an action
Result
What changes in the UI.
- update text
- disable a button
- remove an item