How can I capture a user\'s \"tap\" event with pure JS? I cannot use any libraries, unfortunately.
I wrote a little script myself. It's not in pure-JS, but works fine for me. It prevents executing the script on scrolling, meaning the script only fires on a 'tap'-event.
$(element)
.on('touchstart', function () {
$(this).data('moved', '0');
})
.on('touchmove', function () {
$(this).data('moved', '1');
})
.on('touchend', function () {
if($(this).data('moved') == 0){
// HERE YOUR CODE TO EXECUTE ON TAP-EVENT
}
});