setInterval でボタン連打に対応する
こんな感じだろうか。
index.html
<html> <head> <title>renda sample</title> </head> <body> renda! renda! <button id="renda">renda button</button> <input id="display" type="text"></input> <script src="renda.js"></script> </body> </html>
renda.js
var count = 0; var display = document.querySelector("#display"); display.value = count; var event_buffer = []; function onClick(event) { event_buffer.push(event); console.log(event_buffer); } var renda = document.querySelector("#renda"); renda.addEventListener('click', onClick); function increment() { if (event_buffer.length > 0) { count += 1; display.value = count; event_buffer = []; } console.log(count); } setInterval("increment()", 300);