Reputation: 51
I was wondering if you can detect that an event comes from a passive pen from modern web browsers.
For example on a surface hub, in Edge, you have event.pointerType === 'pen' to distinguish touches made with pen vs those made with a finger but I don't know if you can do the same with any pen on any browser in any OS.
I haven't found any information about it but I am not sure I looked at the right places.
Upvotes: 2
Views: 1874
Reputation: 143
yes and no! passive pen is interpreted as touch BUT you can use pointerevent width and height to guess a touch is passive pen or simple touch. assuming finger has bigger width and height than pen
Upvotes: 0
Reputation: 6465
event.pointerType
is supported by most modern browsers:
https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType
In Firefox it requires that dom.w3c_pointer_events.enabled
be set to true in about:config
. It presents mouse
, pen
, and touch
as values.
Upvotes: 2