简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM