Here I am

home

Hey web-devs, stop listening for EITHER touch or mouse events!

02 Oct 2013

Seriously. It’s annoying. Some devices have a touchscreen and mouse/trackpad. When you do somehting like

if ('createTouch' in document) {
    element.addEventListener('touchstart', clickListener);
}
else {
    element.addEventListener('click', clickListener);
}

I start disliking you. It’s nothing personal, but you’ve just forced me to use the touchscreen of my laptop to interact with your website even if I prefer to use the trackpad or a connected mouse.

When I made the prototype for interact.js, I was guilty of doing the same thing. However, I knew it was the wrong way to go about supporting touch events and I eventually fixed it.