30 seconds of codeBack to Home
Run the callback whenever the user input type changes (
touch). Useful for enabling/disabling code depending on the input device. This process is dynamic and works with hybrid devices (e.g. touchscreen laptops).
Use two event listeners. Assume
mouse input initially and bind a
touchstart event listener to the document.
touchstart, add a
mousemove event listener to listen for two consecutive
mousemove events firing within 20ms, using
Run the callback with the input type as an argument in either of these situations.