This example uses jquery and a JavaScript emulation code that generates mouse events from touch events + detects two fingers gestures. Just add some mouseListeners to your document and it will work both with mouse inputs and touch inputs. By default the emulation code adds touch events to the document but you can adjust the JS code to add events only to any HTML element.