JavaScript Events – Quick Notes
This PDF contains a complete reference for JavaScript events including categories, syntax,
comparison tables, and real-life use cases for quick revision.
Event Syntax Examples
Inline <button onclick="alert('Hello!')">Click</button>
DOM Level [Link]("btn").onclick = function(){ alert("Clicked!"); };
addEventListener (Best) [Link]("btn").addEventListener("click", () => alert("Clicked!"));
Comparison Table of Events
Category Event When it Fires Example
Mouse click Single mouse click [Link]("click", fn)
Keyboard keydown Key pressed [Link]("keydown", fn)
Form submit Form submitted [Link]("submit", fn)
Window resize Window resized [Link]("resize", fn)
Clipboard copy Copy action [Link]("copy", fn)
Drag & Drop drop Item dropped [Link]("drop", fn)
Touch touchstart Finger touches screen [Link]("touchstart", fn)
Media play Media starts playing [Link]("play", fn)
Animation animationend Animation ends [Link]("animationend", fn)
Rare online Browser goes online [Link]("online", fn)
Real-Life Use Cases
Category Event Real-Life Use Case
Mouse click Toggle dark mode, submit form
Keyboard keyup Validate input after typing
Form input Live search suggestions
Window scroll Infinite scroll feed
Clipboard paste Paste Excel data into form
Drag & Drop dragover/drop File upload (Google Drive)
Touch touchmove Swipe gestures on mobile
Media timeupdate Update video progress bar
Animation transitionend Run code after sidebar animation
Rare mutation observerDetect new chat messages