A JavaScript library to detect device input capabilities (mouse, touch, hybrid) and primary input type for responsive UX.
Detect It is a JavaScript library that detects a device's input capabilities and primary input method. It solves the problem of creating device-responsive web applications by providing accurate information about whether a device supports mouse, touch, or both inputs, and which input is primary.
Frontend developers building responsive web applications that need to adapt UX based on device input capabilities, such as those optimizing for touch vs. mouse interactions.
Developers choose Detect It because it handles complex browser inconsistencies and media query triangulation, provides reliable detection tested on real devices since 2016, and integrates seamlessly with modern event handling strategies like Pointer Events.
Detect if a device is mouseOnly, touchOnly, or hybrid, and if the primary input is mouse or touch.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses hover and pointer media queries, Pointer Events API, and Touch Events API detections to triangulate device type, effectively handling browser inconsistencies as detailed in the Detection section.
Tested on numerous devices since 2016 with mocked edge cases, ensuring high accuracy and reliability across diverse environments, as highlighted in the README.
Provides detailed recommendations for event listener setup and device-responsive UX, including examples for Pointer Events and fallback strategies with Event From.
Small bundle size (indicated by bundlephobia badge) and detections occur at import time, minimizing runtime overhead for quick render-time optimizations.
Detections are fixed at render time and do not update if input capabilities change dynamically, such as when a mouse is connected to a tablet after page load.
For example, on iPads, it always reports as hybrid with touch primary, unable to detect attached mice or keyboards due to browser limitations, as admitted in the Detection details.
For projects only needing basic touch support checks, the library's comprehensive approach might be overkill compared to simpler native methods like navigator.maxTouchPoints.