<!DOCTYPE html>
<html onmouseup="end()">
<head>
<meta charset="UTF-8">
<script type="text/javascript">
var counter;
var count = 0;
function start(outp)
{
counter = setInterval(function()
{
console.log(count);
add(outp);
count++;
},500);
}
function end()
{
clearInterval(counter);
}
function add(outp)
{
window.document.form1.Display.value =
window.document.form1.Display.value + outp;
}
</script>
</head>
<body >
<form name="form1">
<button onmousedown="start('x')"onmouseleave="end()" >Click and hold</button>
<input type="text"name="Display"class="display"readonly>
</form>
</body>
</html>
Thats the snippet, the "500" is the delay between each iteration but I have no Idea how to specify the initial delay.
The button normally also has an Onclick event and I want the onmouse event to be triggered after X amount of time.