I have an event listener that is currently being triggered on mousemove. However i want this to only be applied to desktop and not mobile.
And vice versa, for my own reference how would I apply it to mobile only if I wanted to?
Here is my function wrapped around an if statement that if the innerWidth is more than 1000, to trigger add the event listener on mousemove. however I still see it being applied to mobile.
if (window.innerWidth > 1000) {
document.addEventListener("mousemove", debounce(inactiveUser, 10000));
}
If it’s helpful, I am triggering an action event being sent to a tool we use for analytics and campaigns called Evergage. The function is below, along with a console log that I added:
const inactiveUser = () => {
console.log("mouse move on desktop only");
sendEvent({
action: "Inactive Checkout",
});
};