Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the click and tap events?

I am developing an app that runs on Android/iOS and desktop computers.

Should I use the click or the tap event?

What are the differences between them?

Will the 'tap' work on desktop? if not, (and I have to use click) am I missing any advantages that the tap has over the click?

like image 825
Tiger Avatar asked Sep 14 '12 10:09

Tiger


People also ask

What is the difference between tap and click?

Tap usually refers to a physical action like tapping your finger on a screen. (e.g. iPad) Click would be when you use a mouse, to click on a link/image. (e.g. Desktop computer.)

What is a click event?

An element receives a click event when a pointing device button (such as a mouse's primary mouse button) is both pressed and released while the pointer is located inside the element.

Does touch trigger click event?

When a visitor clicks on an image the click event will be triggered. However when someone touches the image, that same click event will be triggered, even if a touchstart event is available as well.


2 Answers

You can use .on() to bind a function to multiple events:

$('#element').on('click tap', function() {     ... }); 

Thanks to @bergie3000 for pointing to this

like image 117
tuned Avatar answered Sep 21 '22 09:09

tuned


Touch events and mouse events are entirely different beasts. They are not interchangeable.

That said, I'm using jQuery Touch Punch which maps touch events to their mouse event analogs, so a tap becomes the same thing as a click. This makes it possibly to use all the standard jQuery UI goodness without having to do any special touch event programming. It's extremely simple to use, and so far has worked perfectly for me on both iDevices and Android.

like image 24
ghoti Avatar answered Sep 18 '22 09:09

ghoti