pointerEnabled

< dom‎ | navigator
Jump to: navigation, search

pointerEnabled

This page has been flagged with the following issues:

High-level issues:


W3C Working Draft

Summary

Indicates if the browser will fire pointer events for pointing input.

Property of dom/navigator

Syntax

Note: This property is read-only.

var result = navigator.pointerEnabled;

Return Value

Returns an object of type Boolean.

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);
  }
});



Related specifications

Specification Status Related Changes
Pointer Events Working Draft Section 5

Compatibility

Desktop

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic Support ?
?
?
IE10 -ms
?
?

Mobile

Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic support ? ? ? ? ? ? ? ?


Compatibility notes

Browser Version Note
Internet Explorer 10 Supported as: msPointerEnabled

See also

Related articles

Pointer Events






  • pointerEnabled