maxTouchPoints

< dom‎ | Navigator
Jump to: navigation, search

maxTouchPoints

This article is Ready to Use.


W3C Working Draft

Summary

The maximum number of simultaneous touch contacts supported by the device.




Property of dom/Navigator

Syntax

Note: This property is read-only.

var result = navigator.maxTouchPoints;

Return Value

Returns an object of type Number.


Compatibility

There is no data available for topic "webapi", feature "maxTouchPoints". If you think that there should be data available, consider opening an issue.

Examples

Basic HTML5 Canvas painting application

JavaScript

<style>
  /* Disable intrinsic user agent touch behaviors (such as panning or zooming) so 
  that all events are given to the application instead. */
  
  html { 
    touch-action: none; 
  }
</style>

<canvas id="drawSurface" width="500px" height="500px" style="border:1px solid black;"></canvas>

<script type='text/javascript'>
window.addEventListener('load', function() {
  var canvas = document.getElementById("drawSurface"),
  context = canvas.getContext("2d");
  if (window.navigator.pointerEnabled) {
    canvas.addEventListener("pointermove", paint, false);
	if(window.navigator.maxTouchPoints>1)
		alert("Your user agent and hardware support multi-touch!");
  } 
  else {
	//Provide fallback for user agents that do not support Pointer Events
    canvas.addEventListener("mousemove", paint, false);
  }
  function paint(event) {
	if(event.buttons>0)
		context.fillRect(event.clientX, event.clientY, 5, 5);
  }
});

Usage

In the case of devices with multiple digitizers (e.g. multiple touchscreens), the value must be the maximum of the set of maximum supported contacts by each individual digitizer.

For example, suppose a device has 3 touchscreens, which support 2, 5, and 10 simultaneous touch contacts, respectively. The value of maxTouchPoints is 10.


Related specifications

Specification Status Related Changes
Pointer Events Working Draft Section 5

See also

Related articles

Pointer Events




  • maxTouchPoints





Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [maxTouchPoints property Article]