Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect MacBook trackpad two-finger tap with JavaScript/jQuery

I wonder if there's any way to detect if the user made a two-finger tap on the MacBook trackpad with JavaScript or jQuery. In one of the projects I'm detecting right mouse click with JavaScript and using it for some actions. It actually doesn't work when you make a double finger tap on a trackpad. While in action that works as a right click, but JavaScript can't detect it like so.

Any clues?

like image 642
cycero Avatar asked Jun 18 '14 16:06

cycero


1 Answers

You can use the mouse events button property - MDN reference

  • A value of 1 would be the indicator of a left click
  • A value of 2 would be the indicator of a right click.

Demo jsFiddle

like image 53
dc5 Avatar answered Nov 09 '22 15:11

dc5