Skip to content
A jQuery plugin that makes it easy to support long press events on mobile devices and desktop borwsers.
Branch: master
Clone or download
vaidik Merge pull request #2 from fightingmonk/master
Add detection of mouse move on non-touch browsers
Latest commit 3eb2dc4 Mar 30, 2014
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore gitignore added Apr 11, 2013
README.md Fix quick usage snippet Dec 13, 2013
jquery.longpress.js add 'cancel on move' support for non-touchscreens Mar 29, 2014

README.md

longpress: a jQuery plugin

Longpress is a jQuery plugin that makes it easy to support long press events on mobile devices and desktop borwsers.

Native Library

If you want something native and more low level than the jQuery implementation, take a look at longpress.js that is also written by me.

Quick Usage

<script type="text/javascript" src="jquery.longpress.js"></script>
$('#button').longpress(function() {
    // longpress callback
    alert('You just longpress-ed a button.');
});

Detailed Usage

.longpress(longpressHandler(event)[, shortpressHandler(event), duration])

longpressHandler(event) Required Type: Function() A function to execute each time someone longpresses something.
shortpressHandler(event) Optional Type: Function() A function to execute each time someone releases the mouse or touch before the longpress duration elapses.
duration Optional Type: Integer longpress duration in milliseconds.

Example:

$('#button').longpress(function(e) {
    alert('You just longpressed something.');
}, function(e) {
    alert('You released before longpress duration and that\'s why its a shortpress now.');
});

Author

Vaidik Kapoor (@vaidikkapoor)

Other

MIT License

Copyright (c) 2008-2013, Vaidik Kapoor (kapoor [dot] vaidik -[at]- gmail [dot] com)

You can’t perform that action at this time.