html5-canvasgoogle-chrome-app

is there a way to get pressure sensitivity of tablet thorugh javascript


I want to make a little painting program. So i am going over if it's even possible. As with all good painting programs it needs to have pressure sensitivity. And i don't think i have ever come across anyway to get pressure sensitivity of mouse/tablet. Is there a workaround.

The thing i have come closest to is touch event that is supposed to have pressure property.

This question has been asked before but that was like in 2009. I am hoping that there would be something available this time.

Chrome apps are also an option.


Solution

  • Hello from the future world of 2022!

    There is a PointerEvent API that appears to be supported by major browsers, and pressure can be read out from the PointerEvent.pressure property.

    tldraw is an example of a project using this API.

    Notes on operating system support for this:

    If you were interested in creating a web-based paint program in 2022, you might have a look at Pressure.js, which claims to support both pressure input and "3D Touch" present on some Apple devices in a single library. I have no first-hand experience with this library, though, so I can't back up those claims.

    It's true this comes 9 years too late for your project. Sorry about that. But this question ranks high in search results for "pressure sensitivity javascript api," so perhaps it can still be useful to someone.