Fabio B.
Fabio B.

Reputation: 9400

jQuery Mobile: catch "finger down" event

I need to detect the user "finger-press", there's already the "tap" event, but tap = press + release.

I need to call a JS function exactly on finger-press, exactly as keypress() does for standard browsers.

Upvotes: 7

Views: 8083

Answers (2)

Federico Zancan
Federico Zancan

Reputation: 4884

There are a couple of events for that already.

They are vmousedown and taphold.

You can find a complete reference about them at this link:

http://jquerymobile.com/demos/1.0/docs/api/events.html

Basically, the jQuery Mobile framework maps the major "traditional" browser UI events prefixing them with a "v".

This is to signal that they are "virtual" events, in that by this mean you can catch events coming from standard (i.e. non-touch) and even touch-oriented devices as well.

So you could install a handler for a vmousedown event with:

$('#your-element-id').live('vmousedown', function() { alert("Hello") });

taphold, instead, is quite different: the event is triggered when a complete tap event takes place with a duration of nearly a second or more.

You can quickly play around with these two events to understand which one better fits your needs.

Upvotes: 7

Alasjo
Alasjo

Reputation: 1240

Do you mean like taphold or vmousedown?

http://jquerymobile.com/demos/1.0/docs/api/events.html

Upvotes: 1

Related Questions