Skip to main content
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

touch

The PointerEvent originated from touch input.

pen

The PointerEvent originated from pen input.

mouse

The PointerEvent originated from mouse input.

"" (empty string)

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

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

PointerEvent
isPrimary