I'm adding two eventListener()'s to a html button so I can detect a long press. It works on safari and firefox on mac but when I open the same webpage in ios on an iphone/ipad or in a simulator the copy/paste popup menu appears.
I found Preventing default context menu on longpress / longclick in mobile Safari (iPad / iPhone) and How to disable the default behavior of an Anchor in jQuery Mobile (iOS).
The popup was solved adding the following to css:
html {
-webkit-user-select: none !important;
-webkit-touch-callout: none !important;
}
If the button is held x ms. it shall perform some function. When I print mouse_delta in an alert message it shows 2 (ms.) even though I hold down the button a few seconds. So it might be a powersaving feature in ios.
Javascript (partial):
var hometeam_goal = document.getElementById("add_goal_hometeam");
hometeam_goal.addEventListener("mousedown", function homegoal_md (event) {
mouse_start = Date.now();
}
hometeam_goal.addEventListener("mouseup", function homegoal_mu (event) {
mouse_delta = Date.now() - mouse_start;
if (mouse_delta < foo) {
<do something>
}
}
How can I work around this on ios?
regards Claus