pointerType
pointerType
This page has been flagged with the following issues:
High-level issues:
Content:
W3C Working Draft
Summary
Indicates the device type that caused the event (mouse, pen, touch, etc.).
Property of dom/PointerEvent
Syntax
Note: This property is read-only.
var result = event.pointerType;
Return Value
Returns an object of type String.
Examples
Detecting the type of input from a user
JavaScript
window.addEventListener("pointerdown", detectInputType, false);
function detectInputType(event) {
switch(event.pointerType) {
case "mouse":
alert("You used a mouse!");
break;
case "pen":
alert("You used a pen stylus!");
break;
case "touch":
alert("You used touch!");
break;
default:
alert("Not sure what device was used!");
}
}
Usage
If a user agent is to fire a pointer event for a mouse, pen stylus, or touch input device, then the value of pointerType must be according to the following table:
| Pointer Device Type | pointerType Value |
|---|---|
| Mouse | mouse |
| Pen Stylus | pen |
| Touch Contact | touch |
If the device type cannot be detected by the user agent, then the value must be an empty string. If a user agent supports pointer device types other than those listed above, the value of pointerType should be vendor prefixed to avoid conflicting names for different types of devices. Future specifications may provide additional normative values for other device types.
Compatibility
Desktop
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic Support | ? | ? | IE10 | ? |
? |
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 | The PointerEvent object and associated events are supported with the MS prefix. E.g., MSPointerEvent |
This tool helps to make and review comments inline.
How to Use
insert instructions, with images, here