JSFiddle - React, Tailwind, and code Playground
HTML
<button class="b-button_hack">Button [hack]</button>
<pre class="b-log"></pre>
JavaScript
var $log = $('.b-log'),
DBLCLICK_INTERVAL = 200, // the default timing in Windows is 500ms
hackTimerId;
function doItOnClick(e) {
$log.append('click\n');
}
function doItOnDblclick(e) {
$log.append('dblclick\n');
}
$('.b-button_hack')
.click(function (e) {
if (hackTimerId) {
hackTimerId = window.clearTimeout(hackTimerId);
}
hackTimerId = window.setTimeout(function () {
doItOnClick(e);
}, DBLCLICK_INTERVAL);
})
.dblclick(function (e) {
if (hackTimerId) {
hackTimerId = window.clearTimeout(hackTimerId);
}
doItOnDblclick(e);
});