MouseDetection
Detects the prescence of a mouse as reliably as possible.
Live demo
The problem
There is currently no 100% way to detect the prescence of a mouse in the browser without making false assumptions. This project attempts to solve this problem.
How?
This project detects the prescence of a mouse based on event acceleration from the mousemove event within a timeframe. If a certain number of events are reached within a specific timeframe it will assume the prescence of a mouse. A promise is resolved when the mouse is detected.
Installation
npm i mouse-detection
Usage
; ;
Why cant I see if a mouse is present right away?
This is not possible since we always have to start on the assumption that we don't know if a mouse exists. The user has to prove this to be false. It's only once the mouse starts moving that we can actually make a reasonable assumption that it's there.