Have a look at the code:
- Code: Select all
document.getElementById(num).onmousedown = function () { SendIRCommand (num,remote,command,led,initial_delay,repeat_delay) };
document.getElementById(num).onmouseup = function () { EndSendCommand (num) };
document.getElementById(num).onmouseleave = function () { EndSendCommand (num) };
"onmousedown" -> pressing the mouse button
"onmouseup" -> releasing the mouse button
"onmouseleave" -> when leaving the button area with the pointer although the button is still pressed
Be advised that starting the send function on releasing the button is not a good idea. This will not work reliably with some mobile devices. Also when will you call the "EndSendCommand" function in such a scenario?