javascript tap and hold
var onlongtouch;
var timer;
var touchduration = 800; //length of time we want the user to touch before we do something
function touchstart(e) {
e.preventDefault();
if (!timer) {
timer = setTimeout(onlongtouch, touchduration);
}
}
function touchend() {
//stops short touches from firing the event
if (timer) {
clearTimeout(timer);
timer = null;
}
}
onlongtouch = function() {
timer = null;
document.getElementById('ping').innerText+='ping\n';
};
document.addEventListener("DOMContentLoaded", function(event) {
window.addEventListener("touchstart", touchstart, false);
window.addEventListener("touchend", touchend, false);
});
Also in JavaScript:
- how to access nested objects in javascript
- react redirect after login
- jquery create input hidden
- nodejs function example
- chart js line and bar
- csv export in react
- js get current seconds
- discord.js bot credits command
- javascript string to ascii array
- npm md to html
- pushing to an array
- how to get selected row index of table in javascript
- javascript getters and setters
- how to use a js class in react
- javascript conver time into 24 hour format
- bootstrap 4 modal popup remote url
- angular serve
- get the location of an item in an array
- axios Cross origin http://localhost forbidden
- how to print array backwards
- aws lambda function setup for node js
- get string value of boolean javascript
- key code
- webview javascript enabled