Course contentsShow
← Web Development
Lesson 757 of 2,98213. DOM EventsFree lesson

Event Object Properties for Different Event Types

Exploring specialized properties like relatedTarget, dataTransfer, touches, and deltaY for specific event categories.

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 during mouseenter, or entering during mouseleave)

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 deltaX for horizontal scrolling and deltaZ for 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.