Can I recognise (graphic tablet) Pen Pressure in Javascript?

后端 未结 5 672
夕颜
夕颜 2021-02-02 03:38

Is there any way to recognise pen pressure using javascript. Preferably I don\'t want to make any use of Flash and try get this done as pure JS.

EDIT: okay I realised th

5条回答
  •  余生分开走
    2021-02-02 03:48

    Javascript as a programming language in itself has no more ability or lack of ability to read this kind of data than any other language.

    The language isn't important. What is important are the APIs available to you from within the language.

    Javascript can be run in a number of different environments, some of which may possibly have access to APIs for this kind of hardware. However most Javascript is run in a web browser environment, and this is clearly what you mean.

    The web browser environment provides a number of APIs. The most obvious is the DOM, which gives you the ability to manipulate the page, etc. There are other APIs available in the browser as well though. For example, the Geolocation API.

    All these are standard APIs which have been defined by the W3C (or in some cases are in the process of being defined by the W3C), meaning that all browsers that support them should make them work the same way.

    Unfortunately for you there isn't a standard API for working with pressure pads, so the direct answer to your question is no, it can't be done.

    Whether one will become available in the future remains to be seen, but I have my doubts.

    There is one way that you can do it though: ActiveX.

    ActiveX is an API provided by Microsoft in older versions of IE. It basically provides a way of accessing virtually any Windows DLL code from within the browser.

    Since the pressure pen device driver for Windows will be provided as a DLL, this means you should theoretically be able to access it in the browser via an ActiveX control. So therefore yes, you would be able to program it using Javascript.

    The bad news, though, is that this is not something I'd recommend. ActiveX as a browser-based technology has long since been abandoned, due to the massive security holes it caused. I don't think the latest versions of IE even support it (I hope not, anyway), which means you'd be forced to use old versions of IE (and only IE - no other browser ever supported it) in order to run your code. Not ideal.

提交回复
热议问题