pointerType property
Returns whether the source of the event is touch, pen or mouse.
This property is read-only.
![]() |
Syntax
| JavaScript |
|---|
ptr = object.pointerType |
Property values
Type: Any
-
The PointerEvent originated from touch input.
-
The PointerEvent originated from pen input.
-
The PointerEvent originated from mouse input.
-
The PointerEvent originated from an unknown input type.
Remarks
In Windows 8.1, this property has been changed to return a string value. In Windows 8, it provided a return value of type long:
- MSPOINTER_TYPE_TOUCH: 0x00000002
- MSPOINTER_TYPE_PEN: 0x00000003
- MSPOINTER_TYPE_MOUSE: 0x00000004
In Internet Explorer 11, this property has been changed to return a string value. In Internet Explorer 10, it provided a return type of long:
- MSPOINTER_TYPE_TOUCH: 0x00000002
- MSPOINTER_TYPE_PEN: 0x00000003
- MSPOINTER_TYPE_MOUSE: 0x00000004
The following example uses pointerType to check whether a pointer is primary from inside events other than onmspointerdown.
elm.addEventListener("pointerdown",handleDown,false); function handleDown(evt) { if(evt.pointerType == "touch") { // Do something for touch input only }else{ // Do something for non-touch input } }
See also
