JavaScript Document createTouch() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

document.createTouch(...) was a legacy factory that creates a Touch object from optional view, target, identifier, and coordinate arguments (MDN). Today it is Deprecated and Non-standard — literacy only.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call document.createTouch. Start with this line.

JavaScript
document.createTouch(view, target, id, pageX, pageY, screenX, screenY)
CallWhat it does
document.createTouch(view, target, id, pageX, pageY, screenX, screenY)Primary signature.
document.createTouch(...)Call with the arguments your case needs.

Built into the browser. Call createTouch(...) on document — no import required.

Library declarations
JavaScript
document.createTouch(view, target, id, pageX, pageY, screenX, screenY)

Parameters

ParameterDescription
viewOptional. Usually window
targetOptional. EventTarget for the touch
identifierOptional. Touch.identifier
pageX / pageYOptional. Page coordinates
screenX / screenYOptional. Screen coordinates

Return Value

Return ValueDescription
*A Touch object (when supported)

JavaScript Examples

Example 1 — Feature-Detect First

Many engines no longer expose createTouch. Always check before calling.

JavaScript
const supported = typeof document.createTouch === "function";
console.log(supported);

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

How It Works

  1. Check the type. Missing methods are "undefined", not callable.
  2. Expect false in most Chromium browsers today.
  3. Branch cleanly so demos do not throw.
  4. Point learners to MDN’s TouchEvent() note.

Example 2 — MDN createTouch Pattern

Recognize this shape in old samples — only run it when the method exists.

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

if (typeof document.createTouch !== "function") {
  console.log("unsupported");
} else {
  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, touch1.pageX, touch1.pageY);
  console.log(touch2.identifier, touch2.pageX, touch2.pageY);
}
Try It Yourself

How It Works

  1. Pick a target element for the synthetic touch.
  2. Guard with feature-detect before calling.
  3. Pass coordinates as in MDN: page then screen pairs.
  4. Read fields like identifier and pageX when supported.

Example 3 — Prefer Modern Input APIs

MDN replacement note: use TouchEvent(); for apps, listen to real events.

JavaScript
// Literacy: do not call createTouch in new apps.
console.log("createTouch deprecated — use TouchEvent() (MDN)");

// Real device input (preferred for products):
window.addEventListener("pointerdown", (e) => {
  console.log(e.pointerType, e.clientX, e.clientY);
});
Try It Yourself

How It Works

  1. Skip the factory for new product code.
  2. MDN path: TouchEvent() when you need a synthetic touch event.
  3. Product path: listen to pointer/touch events from the device.
  4. Recognize createTouch only in old tests or docs.

Browser Support

Document.createTouch() is Deprecated and Non-standard on MDN. It is not part of any current specification. Chromium removed it; do not assume support.

✓ Deprecated · Non-standard

Document.createTouch()

Legacy Touch factory — literacy only. Prefer TouchEvent() or real pointer/touch events.

Legacy Avoid in new code
Google Chrome Removed / unsupported
No
Microsoft Edge Removed / unsupported
No
Opera Removed / unsupported
No
Apple Safari Legacy / check
Partial
Mozilla Firefox Legacy / check
Partial
Internet Explorer No
No
createTouch() Often unsupported

Bottom line: Feature-detect only for legacy demos. See the MDN createTouch() reference.

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.

Next: createTouchList()

Learn the matching deprecated TouchList factory for legacy samples.

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.

18 people found this page helpful