Event Object Properties for Different Event Types
What you'll learn: How different event categories expose specialized properties that give you precise control over mouse, touch, drag, and scroll interactions.
While all event objects share common properties like type, target, and preventDefault(), different event types come with their own specialized properties tailored to the interaction they represent.
Why Specialized Properties Matter
Think of event objects like delivery packages: all packages have a tracking number and destination, but some contain fragile items (with special handling labels), while others include perishable goods (with temperature indicators). Similarly, events carry extra details specific to what happened.
Mouse Event Specializations
You've already seen coordinates (pageX, clientX, etc.) and modifier keys. Mouse events also include:
relatedTarget: Points to a secondary element involved in the event (e.g., the element you're leaving duringmouseenter, or entering duringmouseleave)
Touch and Pointer Specializations
touches: An array-like list of all active touch points on the screen (for multi-touch gestures)- Touch events track where fingers are, how many are active, and their movement
Scroll Event Specializations
deltaY: How much vertical scrolling occurred (positive = down, negative = up)- Also
deltaXfor horizontal scrolling anddeltaZfor depth scrolling
Drag and Drop Specializations
dataTransfer: A special object that carries data being dragged (text, files, URLs) between source and destination
Each event type equips you with exactly the information you need for that specific interaction, avoiding unnecessary clutter while giving precise control.
Key Takeaway: Different event types provide specialized properties—like relatedTarget for mouse transitions, touches for multi-touch, deltaY for scrolling, and dataTransfer for drag operations—that give you detailed context for handling specific user interactions.