JavaScript Document createTouch() Method

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Non-standard
Instance method

What You’ll Learn

document.createTouch() is a deprecated, non-standard instance method that once created Touch objects (see MDN Document: createTouch()). Learn its parameters, MDN’s example, how to feature-detect safely, what to use instead (TouchEvent()), and five try-it labs that still make sense when the API is missing.

01

Kind

Instance method

02

Returns

Touch

03

Args

All optional

04

Prefer

TouchEvent()

05

Status

Deprecated

06

Also

Non-standard

Introduction

A Touch object describes one finger (or stylus contact) on a touch surface — an identifier plus coordinates such as pageX / pageY.

Years ago, some engines exposed document.createTouch(...) so scripts could build those objects by hand (often for tests or synthetic events). MDN now labels the method deprecated and non-standard, and points you to the TouchEvent() constructor instead.

💡
Legacy path vs modern path

Legacy: document.createTouch(view, target, id, pageX, pageY, screenX, screenY)
Modern (MDN): prefer new TouchEvent(...) and real input events
Always: feature-detect before calling createTouch

Related tutorials: createEvent() (also deprecated), createRange(), JavaScript hub.

Understanding document.createTouch()

An instance method on Document that builds a Touch from optional arguments (MDN).

  • Purpose (legacy) — create a configured Touch object (MDN).
  • Parameters — all optional: view, target, identifier, pageX/Y, screenX/Y (MDN).
  • Return value — a Touch object (MDN).
  • Extra old params — clientX/Y, radiusX/Y, rotationAngle, force are deprecated; do not use (MDN).
  • Modern replacement — MDN: use the TouchEvent() constructor.
  • Support reality — often removed; feature-detect every time.

📝 Syntax

General form of Document.createTouch (MDN):

JavaScript
createTouch(view, target, identifier, pageX, pageY, screenX, screenY)

Parameters

MDN: all parameters are optional.

  • view — the window in which the touch occurred (MDN).
  • target — the EventTarget for the touch (MDN).
  • identifier — value for Touch.identifier (MDN).
  • pageX / pageY — page coordinates (MDN).
  • screenX / screenY — screen coordinates (MDN).

MDN also lists older parameters (clientX, clientY, radiusX, radiusY, rotationAngle, force) that should be considered deprecated and not used.

Return value

A Touch object configured as described by the input parameters (MDN).

Exceptions

None highlighted on MDN for the method itself. Calling a missing method throws TypeError — always feature-detect.

MDN example

JavaScript
const target = document.getElementById("target");

const touch1 = document.createTouch(window, target, 1, 15, 20, 35, 40);
const touch2 = document.createTouch(window, target, 2, 25, 30, 45, 50);

⚡ Quick Reference

GoalCode
Feature-detecttypeof document.createTouch === "function"
Legacy create (if present)document.createTouch(window, el, 1, 15, 20, 35, 40)
Read id / pageXtouch.identifier / touch.pageX
MDN modern tipUse TouchEvent() constructor
MDN statusDeprecated & Non-standard

🔍 At a Glance

Four facts about document.createTouch().

Returns
Touch

object

Args
optional

MDN

Prefer
TouchEvent()

MDN

Status
Deprecated

+ Non-standard

📋 When the API exists vs when it does not

Legacy engine with createTouchModern browser (often removed)
typeof createTouch"function""undefined"
MDN exampleMay create Touch objectsThrows if called blindly
Safe approachStill avoid in new productsFeature-detect + modern APIs
Learning goalRead legacy samplesMigrate / replace

Examples Gallery

Examples follow MDN Document: createTouch() and safe feature-detection patterns. On many desktops the method is missing — that is expected.

📚 Getting Started

Detect the legacy API before you touch it.

Example 1 — Feature-detect createTouch

Never assume the method exists on modern browsers.

JavaScript
const supported = typeof document.createTouch === "function";
console.log(supported ? "createTouch available (legacy)" : "createTouch missing");

if (!supported) {
  console.log("Prefer TouchEvent() / real touch or pointer events (MDN).");
}
Try It Yourself

How It Works

Checking typeof avoids a TypeError when the engine removed the legacy factory (common on Chromium desktop).

Example 2 — MDN: create two Touch objects

Same call shape as MDN, guarded by a feature check.

JavaScript
const target = document.getElementById("target");

if (typeof document.createTouch === "function") {
  const touch1 = document.createTouch(window, target, 1, 15, 20, 35, 40);
  const touch2 = document.createTouch(window, target, 2, 25, 30, 45, 50);
  console.log(touch1.identifier, touch2.identifier); // 1 2
} else {
  console.log("createTouch not available");
}
Try It Yourself

How It Works

MDN passes window, a target element, identifiers, then page and screen coordinates. On engines without the API, print a clear fallback message.

📈 Practical Patterns

Inspect legacy Touch fields and plan a modern migration.

Example 3 — Read Touch properties (when available)

Log identifier and coordinates from a created Touch.

JavaScript
const el = document.getElementById("target");

if (typeof document.createTouch !== "function") {
  console.log("skipped — API missing");
} else {
  const t = document.createTouch(window, el, 7, 100, 200, 110, 210);
  console.log(t.identifier); // 7
  console.log(t.pageX, t.pageY); // 100 200
  console.log(t.screenX, t.screenY); // 110 210
  console.log(t.target === el); // true
}
Try It Yourself

How It Works

When the factory exists, the returned Touch exposes the values you passed (MDN parameter mapping).

Example 4 — Modern tip: TouchEvent() / real events

MDN says use the TouchEvent constructor — detect that path instead.

JavaScript
console.log("createTouch:", typeof document.createTouch);
console.log("TouchEvent:", typeof TouchEvent);

// Prefer listening to real input in apps:
document.addEventListener("touchstart", (event) => {
  const first = event.changedTouches[0];
  if (first) console.log("real touch id", first.identifier);
}, { once: true });

console.log("For UI, also consider Pointer Events (pointerdown).");
Try It Yourself

How It Works

Production code should listen for real touches (or pointers), not synthesize legacy Touch objects with a removed Document method.

Example 5 — Optional parameters (MDN)

All arguments are optional — still feature-detect first.

JavaScript
if (typeof document.createTouch !== "function") {
  console.log("createTouch unavailable — cannot demo optional args");
} else {
  const bare = document.createTouch();
  const partial = document.createTouch(window, document.body, 3);
  console.log("bare identifier:", bare.identifier);
  console.log("partial identifier:", partial.identifier);
}
Try It Yourself

How It Works

MDN: every parameter is optional. Defaults differ by engine when the API still exists — another reason not to depend on this method.

🚀 Common Use Cases

  • Reading legacy samples — understand old touch-test helpers.
  • Migrating old code — replace createTouch with standard events / constructors.
  • Interview trivia — know it is deprecated and non-standard (MDN).
  • Not for new apps — use real touch events or Pointer Events.
  • Not a mobile detector — never treat createTouch presence as “is phone”.
  • Paired legacy API — watch for createTouchList in the same old codebases.

🧠 How createTouch() Worked

1

Pass optional fields

view, target, identifier, page/screen coordinates (MDN).

Input
2

Engine builds a Touch

Legacy browsers return a configured Touch object.

Create
3

Often used with TouchList

Old code paired this with createTouchList for synthetic events.

Legacy
4

Migrate away

MDN: prefer TouchEvent(); use real touch / pointer input in apps.

📝 Notes

  • MDN: Deprecated and Non-standard.
  • Not part of any current specification; not on track to become a standard (MDN).
  • Prefer the TouchEvent() constructor (MDN note).
  • All listed primary parameters are optional (MDN).
  • Do not use the older extra parameters (clientX/Y, radius, force, …) (MDN).
  • Related learning: createEvent(), createTextNode(), JavaScript hub.

Limited / Legacy Browser Support

Document.createTouch() is Deprecated and Non-standard on MDN. Logos use the shared browser-image-sprite.png sprite from this project. Many modern engines omit or removed this factory — do not ship new features that depend on it.

Deprecated · Non-standard

Document.createTouch()

Legacy Touch factory — missing in many current browsers. Prefer TouchEvent() and real input events.

Legacy Not for new apps
Google Chrome Legacy createTouch removed / omitted in modern versions
Avoid
Mozilla Firefox Legacy / restricted; do not depend on it for new code
Avoid
Apple Safari Treat as unavailable for new products
Avoid
Microsoft Edge Chromium Edge: treat as unavailable for new code
Avoid
Opera Follow Chromium legacy removal
Avoid
Internet Explorer No practical modern createTouch path
Unavailable
createTouch() Avoid

Bottom line: Feature-detect if you must read legacy code. For new work, use TouchEvent() / real touch events or Pointer Events — never rely on createTouch().

Conclusion

document.createTouch() was a legacy factory for Touch objects. MDN marks it deprecated and non-standard, and recommends the TouchEvent() constructor instead. Feature-detect if you must read old samples, then migrate to real touch or pointer input for production UI.

Continue with createTextNode(), createTouchList(), or the JavaScript hub.

💡 Best Practices

✅ Do

  • Treat this API as historical / migration knowledge
  • Feature-detect with typeof document.createTouch === "function"
  • Follow MDN: prefer TouchEvent() over createTouch
  • Use real touch* or Pointer Events for product UI
  • Watch for paired legacy createTouchList calls

❌ Don’t

  • Use createTouch in new production code (MDN)
  • Call it without a feature check
  • Use the old extra parameters MDN says to avoid
  • Detect “mobile” by checking for createTouch
  • Assume Chromium still ships this factory

Key Takeaways

Knowledge Unlocked

Five things to remember about createTouch()

Legacy Touch factory — deprecated and non-standard.

5
Core concepts
⚠️02

Status

Deprecated

MDN
🛡03

Also

Non-standard

MDN
💡04

Prefer

TouchEvent()

MDN
🔎05

Safety

feature-detect

required

❓ Frequently Asked Questions

MDN: Document.createTouch() creates and returns a new Touch object configured from optional view, target, identifier, and coordinate parameters.
Yes. MDN marks Document.createTouch() as Deprecated and Non-standard. It is not part of any current specification and is no longer on track to become a standard.
MDN: use the TouchEvent() constructor. For real device input, listen to touch events (or prefer Pointer Events). Do not rely on createTouch() in new apps.
MDN: all parameters are optional. Older extra parameters (clientX, clientY, radiusX, radiusY, rotationAngle, force) should be considered deprecated and not used.
Often no. Chromium removed legacy createTouch / createTouchList support years ago. Always feature-detect typeof document.createTouch === "function" before calling it.
Yes. Both were legacy helpers for building Touch / TouchList objects. Both are deprecated non-standard APIs — learn them only for legacy code and interviews.
Did you know?

Some old mobile-detection snippets checked for document.createTouch. That was always unreliable — and today it is worse, because many touch devices no longer expose the method at all. Detect capabilities with feature queries and real events, not removed legacy factories.

Next: createTouchList()

Learn the deprecated non-standard TouchList factory that pairs with createTouch().

createTouchList() →

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.

7 people found this page helpful