Tuesday, April 24, 2012

Repeating Button - If you keep it depressed, it keeps firing a function

I am not sure what to call this, all I can think of is a Repeater Button.

I want to press a button and it fires a function immediately once, eg MyZoom(InOrOut).

But if I keep the mouse button depressed it will keep firing that MyZoom(InOrOut) every one tenth of a second until I release the mouse button.

As you can probably guess from the function name, I will have 2 buttons, a zoom in and a zoom out. They will call MyZoom(-1) to make it smaller and MyZoom(1) to make it bigger.

<button onclick="MyZoom(-1);">Zoom Out</button>
<button onclick="MyZoom(1);">Zoom In</button>

How can I change this to include the repeating effect?

No comments:

Post a Comment