Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Is there a way to detect hover mechanism (or trackpad/mourse)?

I currently have @media (any-hover: hover) condition in my css, and previously with (hover: hover), but neither do what I want: I would like to only enable hover event if a mobile device have some kind of hover mechanism (eg. trackpad, mouse but not limited) implanted.
However, with hover:hover at least on iPad it doesn't stimulate the hover event at all (I know hover detects if the device's primary interaction supports hover), not even I have magic keyboard connected (which has a trackpad). Then I change to any-hover and this time the iPad stimulates hover even without any accessory connected, and is interact with touch.

Hence, is there's a way to detect if a device has hover-able device connected? Should I use pointer: fine or pointer: coarse to do this? Or is there a way to do so in JS? I don't want it simply detect if there's a mouse connected, but any kind of device with hover-like mechanism.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

So you want something that does not match for normal iPads and does match if someone plugs a mouse into an iPad?

pointer: fine is usually enough, but you can get even more precise with (any-hover: hover) and (pointer: fine). You really only want to enable hover content for devices that have fine-grained pointer control.

You can express this in JS as well:

let mql = window.matchMedia('(any-hover: hover) and (pointer: fine');

Then I change to any-hover and this time the iPad stimulates hover even without any accessory connected, and is interact with touch.

That seems like a bug.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!