How can I distinguish individual trackpad touches?

34 Views Asked by At

I'm making an Electron app (I could also switch to Tauri if that would solve my problem). I already know how to monitor wheel events (with event.ctrlKey set to true) to handle pinch-zoom gestures. But this isn't giving me enough information for what I'm trying to do, so I need to go lower-level.

On a tablet or smartphone, I can monitor multiple, concurrent touches using touchstart, touchmove etc. This lets me design my own complex gestures, doing things like adjusting the size/position/rotation of an object all in one gesture.

My question

  1. Is there any way to access individual trackpad touches from JavaScript, so I can design custom multitouch trackpad gestures?
  2. If not, what other options do I have? I'm willing to learn something new and port my app to a new language/framework if necessary to solve this.

What I've found so far: there's something called NSTouch in Apple's AppKit (I'm well out of my depth here) which sounds like it might be how you monitor individual touches on a trackpad on macOS. And there's an experimental library of Rust bindings for AppKit named cacao, so I'm wondering if there's some way I could switch to Tauri and use Rust to get hold of the low-level trackpad touches while still using HTML/CSS/JS for other parts of my app...? If that's not possible/feasible, maybe I need to learn Swift or something? (I'd prefer to stay with a cross-platform toolkit but wouldn't mind doing something macOS-only for now if that's the best way to start making progress, and worry about porting to other systems later).

0

There are 0 best solutions below