Repeat mouse click function when the key is clicked

Repeat mouse click function when the key is clicked

Hi friends,
I have a problem. This is my javascript code to generate of 10 next numbers around range when user will click:
  1.         // vars
  2.         var step = Number(100);
  3.         var min = Number(100);
  4.         var max = Number(1000000);
  5.        
  6.         // init
  7.         $("#ActMin").attr("value", min);
  8.         $("#ActMax").attr("value", 10*min);
  9.        
  10.         var x = min;
  11.         $("#Measure").html("");
  12.         while (x <= (10*min)) {
  13.             $("#Measure").append("<span class=\"Value\">"+x+"</span>");
  14.             x = x+step;
  15.         }
  16.        
  17.         // script
  18.         $("#ButtonRight").click(function() {
  19.             var actMin = Number($("#ActMin").attr("value"));
  20.             var actMax = Number($("#ActMax").attr("value"));
  21.            
  22.             if(actMax<max) {
  23.                 $("#ActMin").attr("value", actMin+step);
  24.                 $("#ActMax").attr("value", actMax+step);
  25.                 var x = Number($("#ActMin").attr("value"));
  26.                 $("#Measure").html("");
  27.                
  28.                 while (x <= Number($("#ActMax").attr("value"))) {
  29.                     $("#Measure").append("<span class=\"Value\">"+x+"</span>");
  30.                     x = x+step;
  31.                 }               
  32.             } else {
  33.                 alert("Err");
  34.             }
  35.         });
and html:
  1.     <div class="Measure" id="Measure"></div>
  2. <input type="hidden" name="" value="" id="ActMin" />
  3. <input type="hidden" name="" value="" id="ActMax" />
  4. <span id="ButtonRight"></span>
How to do so that when the user still is keeping the pressed key the function repeats itself? Must I use mousedown event? If so it in what way to stop repeating the function after letting go of the key?

Very thanks for answers,
Kamil

PS Sorry for my English, im from Poland ;)