23

I am using .on("touchstart mousedown",function (e) {pTouchDown(e)});

Its working with one finger touch, but I want to do some operation with two-finger touch too.

vikrant
  • 2,169
  • 1
  • 21
  • 27
Arvind Rohit
  • 233
  • 1
  • 2
  • 6

1 Answers1

41

The touch events contain a property, called touches, which contains all the touch points available. You can read more about TouchEvents on MDN.

In your case, you would need to check the length of the touches property:

someElement.addEventListener('touchstart', function (e) {
  if(e.touches.length > 1) {
    // ... do what you like here
  }
});

Or with jQuery:

$someElement.on('touchstart', function (e) {
  if (e.touches.length > 1) {
    // ... do what you like here
  }
});
joe
  • 3,752
  • 1
  • 32
  • 41
Tudmotu
  • 845
  • 8
  • 11