最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to detect if pointer coarse or fine - Stack Overflow

programmeradmin3浏览0评论

I read this about interaction media which is explain how css can detect if pointer is touchscreen or not. It's using @media query like

@media (pointer: coarse){
  body{
    // do something
  }
}

but I just wonder how to implementing it using javascript ot JQuery, is it possible?

Thank you

I read this about interaction media which is explain how css can detect if pointer is touchscreen or not. It's using @media query like

@media (pointer: coarse){
  body{
    // do something
  }
}

but I just wonder how to implementing it using javascript ot JQuery, is it possible?

Thank you

Share Improve this question edited Apr 25, 2024 at 13:20 Lucky asked Feb 8, 2017 at 4:29 LuckyLucky 2,0824 gold badges24 silver badges40 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 22
is_fine = matchMedia('(pointer:fine)').matches
is_coarse = matchMedia('(pointer:coarse)').matches

Works in Chrome for me.

发布评论

评论列表(0)

  1. 暂无评论