Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting mouse support

This is the opposite of detecting touch support in browsers. How can I detect if a browser has mouse support? Chrome for desktop should return true, Safari for iPad should return false.

I'm thinking that mobile browsers will return false positives for the usual detection tricks.

like image 769
Matthew Avatar asked Jan 20 '12 00:01

Matthew


1 Answers

In browsers that use Touch Events:

var clickEvent = ('ontouchstart' in window ? 'touchend' : 'click'); is basically saying “if the device support touch, only listen to touchend and not click” – which, on a multi-input device, immediately shuts out any interaction via mouse, trackpad or keyboard.

This article discusses your question in details here

Another insightful article here

But, it all depends on what you want to achieve.

like image 151
Devendra Bhatte Avatar answered Oct 29 '22 06:10

Devendra Bhatte