How to capture touch pad input
Asked Answered
R

4

35

I've looked everywhere for how to capture touch pad input for laptops but I can't seem to find anything for Chrome extensions/JavaScript.

Question: how can I capture the number of fingers down (not clicked, just down and potentially moving as you would with a mouse), their corresponding x,y coordinates, and their corresponding up events, for a touch pad on a laptop?

Clarifications:

  • I'm not interested in detecting touch screen events. Just touch pad events.
  • Can assume the touch pad lives on 3 year old or newer lap tops.
Replacement answered 24/12, 2015 at 6:23 Comment(1)
You can't. There's no such API.Ladylove
T
1

to develop such kind of extension, you need to write chrome native client with Windows Touch Input to make it happen.

Taco answered 2/1, 2016 at 19:36 Comment(2)
Yes, technically you're correct. Could you expand and provide a little more detail on how this would be accomplished persistently? Aka a native exe that'd be running constantly in the background picking up touch pad events and communicating any input back to the chrome extension.Replacement
well, i don't have any specific information available, but i would suggest you take a look at google's native client SDK samples to get an idea.Taco
J
4

I can't find it by now, but I somewhere read about this topic. But the synopsis is simple: it's a draft/in development but no browser supports it by now. Here is the W3C draft: https://w3c.github.io/pointerevents/

Jolda answered 26/12, 2015 at 20:46 Comment(5)
Hmm, I do know that on Mac it is possible to detect that one finger is down and then a second finger taps. There are extensions that utilize the capability. Possibly some alternative/special API method within a Chrome extension on Windows?Replacement
Well, but than it would be interesting to know how this works. But as I know the new pointerevents is the only spec for this and that there is no solution that will work for all browsers and without special extensions. And I guess there is only very limited usage of javascript events that are only supported by extensions. For OSX there is an extension for Safari: smus.com/multi-touch-browser-patchJolda
Hmmm if this is possible it may be how they do it on OSX as a chrome extension. Any thoughts?Replacement
Well from my perspective, everything that is not implemented in a browser by default is not worth thinking about. And VB, ActiveX and AutoHotkey are horrible tools for applications.Jolda
I definitely agree. Tthis question on the other hand is for a Chrome extension. So you can make assumptions :)Replacement
P
2

I think it is not possible to do this using JavaScript only. Let's take it this way:

Consider the following situation:

I am using a Macbook pro 13in Retina Display, with multi touch and multi gesture touchpad.

Now Suppose if I have gesture settings in my Operating System that if I tap two fingers, register it as a normal Left Click, and when I tap a single finger, register it as a right click.

Now imagine we are capturing both the events, click and dblclick, now tell me which event will get fired when I will do a single tap with one finger. It will be a dblclick, and when I will do a tap with two fingers it will be click event fired.

Another Case: Imagine i have inverted scrolling turned on in my computer, now when I will scroll upwards my page will scroll downwards. And this is something which chrome/ firefox is not controlling.

Conclusion: There can be varied number of such settings across varied types of operating system, across varied number of devices such as trackpads, trackballs, touchpads, mouse, magic mouse etc. This gives me a feel that there is a layer between the external hardware and the browser detecting the firing events and this layer is provided by the operating system. Its operating system which manipulate the events according to the user defined/preset settings.

There can be devices which intent to provide and fire multiple events like touch device, on touch they fire multiple events. But that is not the case with all the devices. So it doesn't matter if you are clicking from mouse or from the trackball or from the touchpad or from the touch screen you will get one common event that is a click, there is definitely a possibility that some more events are fired but they are dependent on the type of device and not on the settings you have done in your Operating System.

One way you can capture is the event is by establishing some sort of connectivity between your browser web page and operating system as suggested by @AlvaroSanz.

Perionychium answered 2/1, 2016 at 9:25 Comment(1)
This approach wouldn't work for a down finger just navigating around the page like a mouse page.Replacement
M
1

I know that you´re asking for a solution for Chrome extensions/JavaScript but I´ve been searching and getting nothing, so I finished with a possible solution combining VB and JavaScript.

There is VB api for Synaptics (https://autohotkey.com/board/topic/65849-controlling-synaptics-touchpad-using-com-api/) and you can call javascript from VB (http://www.codeproject.com/Articles/35373/VB-NET-C-and-JavaScript-communication#cjfv), it's a long way, but it's a way.

Mcgary answered 26/12, 2015 at 23:33 Comment(4)
VB and JavaScript seem to only apply in IE. However, there is an IETab extension for Chrome which looks to fire up IE and present itself in Chrome which enables ActiveX (used to write VB that communicates with JavaScript). Do you know of a way to do something similar and execute an external executable to read the state of the touchpad?Replacement
Here says something about native messaging that allows you to communicate a chrome plugin with an app. For launching an external executable you could use NPAPI plugins, but is being phased out, more infoMcgary
I'd love to mark an answer as correct for the bounty. If you could provide a suppper simple sample (feel free to assume lots) utilizing native messaging and some sort of continuous monitoring of trackpad input in a native app I'd be more than happy to mark this as correct.Replacement
Let me a few days, lot of compromises these days :)Mcgary
T
1

to develop such kind of extension, you need to write chrome native client with Windows Touch Input to make it happen.

Taco answered 2/1, 2016 at 19:36 Comment(2)
Yes, technically you're correct. Could you expand and provide a little more detail on how this would be accomplished persistently? Aka a native exe that'd be running constantly in the background picking up touch pad events and communicating any input back to the chrome extension.Replacement
well, i don't have any specific information available, but i would suggest you take a look at google's native client SDK samples to get an idea.Taco

© 2022 - 2024 — McMap. All rights reserved.