pen/stylus support in web browsers
Asked Answered
E

6

17

Are there any web browsers that make pen/stylus specific events (such as pressure) available to the DOM, similar to Microsoft's RealTimeStylus API?

Is there any standard DOM interface for this? If not, are there proprietary extensions that allow this, perhaps using a plugin?

Energy answered 14/11, 2010 at 9:2 Comment(1)
I've been searching for something similar: or even the ability to use tags (or tangible tags, rfIds) that are detected. Did you find anything?Mathematical
B
6

According to the current APIs, you can't retrieve pressure. However, there is a browser plugin from Wacom.

DeviantArt Muro seems to use it.

Bertle answered 30/5, 2013 at 0:45 Comment(0)
G
4

The Pointer Events API is a set of events that pointer devices can trigger. The event objects are similar to what you get for mouse events, but they do add properties for attributes like pressure. These events are supported by current releases of all modern browsers.

Giesser answered 9/5, 2019 at 23:41 Comment(0)
O
3

If the browser implements support for "pointerevent.pressure", then it should be able to support pressure-sensitive input. For tilts and twists, the equivalent features would be "ponterevent.tiltx", "pointerevent.tilty" and "pointerevent.twist".

See for more information.

Openhearth answered 8/5, 2017 at 10:14 Comment(0)
E
2

No browser currently exposes such APIs.

However, depending on the pen/digitizer drivers, the pen events might look to the browser like touch events, which many browsers have implemented. You can test this in Chrome and Firefox (via Firebug) with the monitorEvents function available in their consoles. Simple call:

monitorEvents(document);

In the console, then see if the browser captures the desired event. I tried this with my own Lenovo X200 tablet, but none of the non-standard events from my pen register (they all appear as mouse events).

I don't know of any third-party extensions that allow this, and a Google search doesn't turn up anything useful.

Entrepreneur answered 3/6, 2012 at 19:39 Comment(1)
I added an answer to give an update on this issue. Lets keep our fingers crossed!Londalondon
L
2

Here is a possible working solution with a polyfill: hand.js.

See this great MSDN article on the hand.js.

I recommend using a library to smooth out paths. I've had good luck implementing something in paper.js when playing with touch on my hp tablet, I can't imagine it would be too hard to make the points adapt to pressure sensitivity.

There is support for it within html5 windows 8 apps. Sadly this API hasn't been exposed to actual browsers AFAIK.

It looks like there is a W3C recommendation in the pipeline that appears to be based on it. It seems like they are working on the recommendation based on the drafts stored in their repo.

See Quickstart: Capturing ink data (HTML) about using it in windows 8 apps.

Londalondon answered 8/6, 2014 at 8:31 Comment(0)
R
0

This may not be a very practical suggestion or something a bit overkill, but if there are APIs / SDKs that expose the pen / stylus to the desktop, you could create a webservice type of application that would update a page in real time with the input from the device. I don't however have any code to help you with this, nor do I know if it would be possible to do this without impossible lag.

Rhine answered 26/1, 2015 at 20:24 Comment(1)
Additionally, you could mix the two approaches: use a webservice to feed your webapp with pressure information, and a supported plugin/library to handle the remaining input.Intrepid

© 2022 - 2024 — McMap. All rights reserved.