Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

PointerEvent.pointerType

This article needs a technical review. How you can help.

Summary

Indicates the device type that caused the pointer event. The supported values are the following strings:

mouse
The event was generated by a mouse device.
pen
The event was generated by a pen or stylus device.
touch
The event was generated by a touch such as a finger.

If the device type cannot be detected by the browser, the value can be an empty string (""). If the browser supports pointer device types other than those listed above, the value should be vendor prefixed to avoid conflicting names for different types of devices.

This property is Read only .

Syntax

var pType = pointerEvent.pointerType;

Return value

pType
The event's pointer type, either the string mouse, pen or touch.

Example

This example illustrates using the value of the pointerType to call the appropriate pointer type processing function.

targetElement.addEventListener("pointerdown", function(ev) {
   // Call the appropriate pointer type handler
   switch (ev.pointerType) {
     case "mouse": 
       process_pointer_mouse(ev); 
       break;
     case "pen": 
       process_pointer_pen(ev); 
       break;
     case "touch": 
       process_pointer_touch(ev); 
       break;
     default:
       console.log("pointerType " + ev.pointerType + " is Not suported");
   }
 }, false);

Specifications

Specification Status Comment
Pointer Events – Level 2
The definition of 'pointerType' in that specification.
Editor's Draft Non-stable version.
Pointer Events
The definition of 'pointerType' in that specification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support No support (Yes) [1] 10 No support No support
Feature Android Android Webview Chrome for Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support No support No support No support No support No support 10 No support No support

[1] Implementation withdrawn. See bug 1166347.

Document Tags and Contributors

 Contributors to this page: rolfedh, AFBarstow
 Last updated by: rolfedh,