Brick,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<span>0</span>
<button>up</button>
<script>
let up;
const span = document.querySelector("span"),
button = document.querySelector("button");
(function num(i) {
up && (span.textContent = ++i);
setTimeout(num, 300, i);
})(0);
button.addEventListener("mousedown", function() {
up = true;
})
button.addEventListener("mouseup", function() {
up = false;
})
</script>
</body>
</html>