<button id="but">click</button>
<script>var but = document.getElementById('but');
but.addEventListener('mousedown', function () {
but.setAttribute("data-_clk_",
String( setTimeout(
function() {
but.removeAttribute("data-_clk_");
alert('ta-dam');
}, 3000)
)
);
}, false);
but.addEventListener('mouseup', function () {
if ( but.getAttribute("data-_clk_") ) {
clearTimeout( Number( but.getAttribute("data-_clk_") ) );
but.removeAttribute("data-_clk_");
}
}, false);
</script>