Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect double tap on ipad or iphone screen using javascript

I'd like to detect if a user has double tapped on an ipad or iphone.

Does a javascript-event exist which would provide this functionality?

like image 277
enne87 Avatar asked Jan 11 '12 19:01

enne87


People also ask

How do I set my iPhone to double tap the screen?

Turn on Back Tap Check that you have the latest version of iOS on your iPhone 8 or later. Go to Settings > Accessibility > Touch, and tap Back Tap. Tap Double Tap or Triple Tap and choose an action. Double or triple tap on the back of your iPhone to trigger the action you set.

Why isn't my double tap working on my IPAD?

Question: Q: Double tap not working It might be that you're not tapping fast enough if neither works for you. You can adjust the speed by which you're expected to double-tap by going to Settings > Accessibility > Side Button.

Does iPhone have double tap to lock?

Did you know you can double tap the back of your iPhone to lock your screen? Through the Back Tap feature, you can do just that and more. The feature came with iOS 14, and should work with most iPhones.


1 Answers

This could be used for a double tap or a double click. In pure javascript:

var mylatesttap; function doubletap() {     var now = new Date().getTime();    var timesince = now - mylatesttap;    if((timesince < 600) && (timesince > 0)){      // double tap        }else{             // too much time to be a doubletap          }     mylatesttap = new Date().getTime();  } 
like image 177
Jorge Avatar answered Oct 02 '22 13:10

Jorge