JavaScript Element touchstart Event

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
DOM event
Instance event

What You’ll Learn

The touchstart event fires when one or more touch points are placed on the surface. Learn TouchEvent, changedTouches, press patterns, multi-touch counts, Pointer Events alternatives, and five try-it labs.

01

Kind

Instance event

02

Type

TouchEvent

03

When

Finger down

04

Handler

ontouchstart

05

Bubbles?

Yes

06

Status

Limited availability

Introduction

touchstart is the beginning of a touch gesture: one or more fingers (or stylus contacts that go through Touch Events) touch the surface. Use it to mark “pressed,” start a drag, or record the initial contact point.

After start comes touchmove while sliding, then touchend on lift—or touchcancel if the system aborts. For new cross-device UIs, prefer pointerdown.

💡
Beginner tip

Do not use "ontouchstart" in window alone to decide “this is a phone.” Many desktops hide or expose Touch Events for compatibility reasons. Detect the APIs you need, or use Pointer Events.

Understanding touchstart

An instance event that answers: “Did one or more fingers just touch down?”

  • Trigger — touch points placed on the surface.
  • Event typeTouchEvent; use changedTouches.
  • Bubbles — yes; cancelable behavior can vary by UA.
  • Starts the chain — often followed by move / end / cancel.
  • Limited availability on MDN (not Baseline)—desktop Safari often lacks Touch Events.

📝 Syntax

Use the event name with addEventListener, or set the handler property:

JavaScript
addEventListener("touchstart", (event) => { });

ontouchstart = (event) => { };

Event type

A TouchEvent (inherits from UIEvent / Event).

Handy TouchEvent properties

PropertyMeaning
changedTouchesTouch points that just went down
touchesAll current contacts on the surface
targetTouchesContacts that started on this target and are still down
altKey / ctrlKey / metaKey / shiftKeyModifier keys at event time

Passive tip

Prefer { passive: true } when you only observe the start and do not call preventDefault().

⚡ Quick Reference

GoalCode / note
Listen (passive)el.addEventListener("touchstart", fn, { passive: true })
Handler propertyel.ontouchstart = fn
New pointsevent.changedTouches
Start positionchangedTouches[0].clientX / clientY
How many down?event.touches.length
MDN statusLimited availability (not Baseline)

🔍 At a Glance

Four facts to remember about touchstart.

Event type
TouchEvent

changedTouches

Means
down

Gesture start

Bubbles
true

Listen on el

Baseline
no

Limited availability

Examples Gallery

Patterns follow MDN Element: touchstart event and the Touch events guide. Use a touch device or DevTools touch simulation; some labs include mouse fallbacks for desktop practice.

📚 Getting Started

Listen for finger down and read the TouchEvent.

Example 1 — Log touchstart

Print how many new points went down.

JavaScript
const pad = document.getElementById("pad");
const out = document.getElementById("out");

pad.addEventListener("touchstart", (event) => {
  out.textContent =
    "touchstart · down=" + event.changedTouches.length;
}, { passive: true });
Try It Yourself

How It Works

changedTouches lists the contacts that just started; touches lists every contact still on the surface.

Example 2 — ontouchstart Property

Same idea using the handler property form.

JavaScript
const pad = document.getElementById("pad");
const out = document.getElementById("out");

pad.ontouchstart = (event) => {
  out.textContent = "ontouchstart fired";
};
Try It Yourself

How It Works

Prefer addEventListener when you need multiple listeners, passive options, or easy removal.

📈 Press, Multi-Touch & Detect

Style on press, count contacts, and feature-detect.

Example 3 — Press Style + Start Position

Add a pressed class and log where the first finger landed.

JavaScript
const pad = document.getElementById("pad");
const out = document.getElementById("out");

pad.addEventListener("touchstart", (event) => {
  pad.classList.add("pressed");
  const t = event.changedTouches[0];
  out.textContent = t
    ? "start x=" + Math.round(t.clientX) + " y=" + Math.round(t.clientY)
    : "start";
}, { passive: true });

pad.addEventListener("touchend", () => pad.classList.remove("pressed"));
pad.addEventListener("touchcancel", () => pad.classList.remove("pressed"));
Try It Yourself

How It Works

Always clear press styles on both touchend and touchcancel.

Example 4 — Multi-Touch Contact Count

Show how many fingers are currently down using touches.length.

JavaScript
const pad = document.getElementById("pad");
const out = document.getElementById("out");

function showCount(event) {
  out.textContent = "fingers down=" + event.touches.length;
}

pad.addEventListener("touchstart", showCount, { passive: true });
pad.addEventListener("touchend", showCount);
pad.addEventListener("touchcancel", showCount);
Try It Yourself

How It Works

touches is the live set of contacts; update the count on start, end, and cancel.

Example 5 — Feature Detect + Pointer Fallback Note

Check Touch Events support; prefer Pointer Events when building new UIs.

JavaScript
const out = document.getElementById("out");
const hasTouch = "ontouchstart" in window;

out.textContent = hasTouch
  ? "Touch Events available — listen for touchstart"
  : "No Touch Events — use Pointer Events (pointerdown)";

if (hasTouch) {
  document.getElementById("pad").addEventListener(
    "touchstart",
    () => { out.textContent = "touchstart received"; },
    { passive: true }
  );
}
Try It Yourself

How It Works

Use this check to choose an API path—not as a standalone “is mobile” detector.

🚀 Common Use Cases

  • Apply pressed / active styles when a finger goes down.
  • Record the initial point for drag, swipe, or drawing.
  • Start long-press timers that cancel on move / end.
  • Count simultaneous fingers for multi-touch gestures.
  • Migrate toward pointerdown for mouse + pen + touch.

🔧 How It Works

1

Contact begins

Finger (or touch contact) meets the surface on an element.

Down
2

touchstart fires

TouchEvent with changedTouches for the new points.

Event
3

Gesture continues

touchmove while sliding; then touchend or touchcancel.

Chain
4

Start your UI state

Pressed styles, drag origin, timers—clean up on end/cancel.

📝 Notes

  • MDN: Limited availability (not Baseline)—no Deprecated / Experimental / Non-standard banner.
  • Prefer { passive: true } when you only observe the start.
  • Do not use ontouchstart alone as a mobile device detector.
  • Prefer Pointer Events for new cross-device interaction code.
  • Related learning: touchmove, touchend, pointerdown, addEventListener(), JavaScript hub.

Limited Browser Availability

touchstart is marked Limited availability on MDN (not Baseline). Logos use the shared browser-image-sprite.png sprite from this project. Touch Events are strong on mobile; many desktop browsers omit them—prefer Pointer Events for cross-device UIs.

Limited availability

Element touchstart

Fires when touch points are placed on the surface. Chrome 22+, Firefox 52+, Edge 12+, Safari iOS yes; desktop Safari often no.

Partial Not Baseline
Google Chrome 22+ (touch-capable / mobile)
Supported
Mozilla Firefox 52+ (desktop re-enabled)
Supported
Apple Safari iOS yes · desktop often no
Partial
Microsoft Edge 12+
Supported
Opera Mobile / Chromium touch paths
Partial
Internet Explorer Not supported (use Pointer Events)
Unavailable
touchstart Limited

Bottom line: Use touchstart to begin Touch Events gestures. Pair with move/end/cancel, and prefer pointerdown for mouse + pen + touch together.

Conclusion

touchstart is the “finger down” signal that begins a Touch Events gesture. Read changedTouches, start your UI state, continue with move/end/cancel, and consider Pointer Events for cross-device input.

Continue with transitioncancel, touchmove, pointerdown, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use { passive: true } when you only observe the start
  • Read new contacts from changedTouches
  • Clear press/drag state on touchend and touchcancel
  • Prefer Pointer Events for new multi-input UIs
  • Test with DevTools touch simulation or a real phone

❌ Don’t

  • Treat ontouchstart as a reliable “is mobile” test
  • Leave pressed styles stuck if cancel fires instead of end
  • Assume desktop Safari exposes Touch Events
  • Skip pairing with move / end / cancel for drag UIs
  • Overwrite ontouchstart if you need multiple listeners

Key Takeaways

Knowledge Unlocked

Five things to remember about touchstart

Finger down—start the gesture, then handle move, end, or cancel.

5
Core concepts
📄02

TouchEvent

changedTouches

API
👆03

Press

start UI state

Pattern
👥04

Multi

touches.length

Count
🎯05

Limited

prefer pointerdown

Status

❓ Frequently Asked Questions

It fires when one or more touch points are placed on the touch surface—the start of a touch gesture.
No. MDN does not mark Element touchstart as Deprecated, Experimental, or Non-standard. It has Limited availability (not Baseline), mainly because desktop Safari and some desktop browsers omit or limit Touch Events.
A TouchEvent. Use changedTouches for the points that just went down; also inspect touches and targetTouches as needed.
No. Many desktop browsers hide or expose Touch Events in ways that make “has ontouchstart” a poor mobile detector. Prefer feature detection for the APIs you use, or Pointer Events for cross-device input.
touchstart is Touch Events only. pointerdown works for mouse, pen, and touch. For new cross-device UIs, prefer Pointer Events.
Usually touchmove while sliding, then touchend on lift—or touchcancel if the gesture is aborted.
Did you know?

Sites that branch on "ontouchstart" in document often break on touchscreen laptops—either forcing a mobile layout on desktop, or missing touch because the browser hid the API. Prefer Pointer Events for input.

Next: transitioncancel

Learn when a CSS transition is canceled mid-flight.

transitioncancel →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful