It's 2016 and plenty of devices have both touch and mouse-like inputs for several years now. "Can't touch" is not a good way to judge "Can mouseover". To give just a few examples:
- "Active pen" digitizer devices like Galaxy Note phones and tablets (Android), Microsoft Surface (Windows) and Wacom Cintiq (Mac/Windows/Android), and I believe the iPad Pro too, where the pen works like a mouse and can "air hover" when around 1cm from the screen
- Windows laptops / hybrids with touchscreens plus and convential laptop trackpads etc
- Touchscreen monitors that can be attached to any PC and used with a mouse
So a user could be unable to hover one minute, then, on the same device, without refreshing the page, they pull the pen out of their Galaxy Note and (assuming it doesn't catch fire) they suddenly are using hover in their interaction, and they expect it to Just Work.
If you need to know if your user a) can use and b) currently is using a device that enables them to conveniently mousover things, you could:
- Bind a
mousemove
event to your document body
that activates a "has hover" state (e.g. adding a class user-can-mouseover
to body
) if a mousemove-triggering cursor is moving, and then immediately unbinds itself so it only happens once.
- Also bind a
touchstart
event that temporarily deactivates that mousemove
and a touchend
that reactivates it, so that, on browsers that trigger mouse events on touch (quite common on Android and Windows), normal touch scrolling doesn't trigger the mousemove
.
- Have the
mousemove
event unbind these touchstart
and touchend
events for good housekeeping
This would then cause the "can hover" state to be triggered any time a user starts using an input device that behaves like a mouse.
For example, taking a hybrid device:
- Initially, the user is browsing the web using touch and swipe.
- They reach your application, swipe up and down using touch while understanding what it is. So far, the "can hover" condition isn't active.
- They decide this is one of those cases where they want more accuracy than their fat fingers allow, so they pull out the digitizer pen or reach for their mouse.
- This causes the cursor to move across the page without an unended touch event having happened, so your "can hover" condition is triggered
...and taking an old-school desktop workstation with a mouse:
- The page loads.
- The user moves the mouse while doing anything, immediately triggering the mouse move event
- The "can hover" state is triggered immediately