A lightweight, framework-agnostic library for detecting multi-finger tap gestures on touch devices.
npm install multi-finger-tap- 🎯 Detect 1, 2, 3, or more finger taps
- 🪶 Lightweight
- ⚛️ React hook included
- 🌐 Works in all modern browsers
- 💪 Written in TypeScript
- 🔧 Fully typed
import MultiFingerTap from 'multi-finger-tap';
const element = document.getElementById('touch-area');
const detector = new MultiFingerTap(element, {
onDoubleTap: () => console.log('Two fingers!'),
onTripleTap: () => console.log('Three fingers!'),
});
// Clean up
detector.destroy();import { useRef, useEffect } from 'react';
import { useMultiFingerTap } from 'multi-finger-tap';
function App() {
const touchRef = useRef(null);
useEffect(() => {
const cleanup = useMultiFingerTap(touchRef, {
onDoubleTap: () => alert('Two finger tap!'),
onTripleTap: () => alert('Three finger tap!'),
});
return cleanup;
}, []);
return <div ref={touchRef}>Tap here</div>;
}maxDuration(number): Max tap duration in ms (default: 300)preventDefault(boolean): Prevent default touch behavior (default: true)onTap(function): Called for any tap with finger countonSingleTap(function): 1 finger taponDoubleTap(function): 2 finger taponTripleTap(function): 3 finger taponMultiTap(function): 4+ finger tap
MIT