long-press-event is a 1k script that adds a long event to the DOM using CustomEvent and a pure JavaScript library that detects and handles a long press/click event on a specific DOM (or the entire document). Supports both desktop and mobile.
It works in IE9 +, Chrome, Firefox, and Safari as well as popular mobile browsers including the Cordova (Phone Gap) apps.
detect long press javascript, disable long press javascript, long press event in react js, angular long press event, long key press event in javascript, react long press
How to make use of it:
Import the long-press.js library into your HTML document.
<script src="dist/long-press.min.js"></script>
Attach the long-press/tap occasion handler to a selected component.
var el = document.getElementById('demo'); el.addEventListener('long-press', function(e) { // do something });
Or connect the occasion handler to the whole doc.
document.addEventListener('long-press', function(e) { // do something });
Customize the time delay in milliseconds.
<div id="demo" data-long-press-delay="500">Press and hold me for .5s</div>
Handle Long Press/Tap Event, long-press-event Plugin/Github, long press event in cordova, press and hold javascript
See Demo And Download
Official Website(john-doherty): Click Here
This superior jQuery/javascript plugin is developed by john-doherty. For extra Advanced Usages, please go to the official website.
Be First to Comment