Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto repeat the up/down arrow key?

in firefox when im inside a input textbox and press down the up/down arrow key it doesn't autorepeat. how can i make that happen and control how many keypress it will fire up per sec?

UPDATE: i use:

$('#search_view #search').live('keydown', function(event) {
    if(event.keyCode == 40) {
       // code
    }
});

but it just execute the code one time..i would like it to repeat when holding down the down-arrow.

like image 607
ajsie Avatar asked Nov 06 '22 16:11

ajsie


1 Answers

Use .keydown() instead ..

quote from jQuery .keypress()

In addition, modifier keys (such as Shift) cause keydown events but not keypress events.

Arrows fall do not fall in the same category as Shift, but are treated in a special way ... the keydown will do the trick ..

Update

After your comment here is a sample that works in

  • FF 3.5.x and 3.0.11
  • IE 6, 7
  • Google Chrome 4.0.x
  • Safari 4.0.4

It only does not work on Opera (Edit: works on Opera 12.16) but it does not work with any key .. not just the arrows..

About the rate, you can not alter it from your code.. it is a system option (from BIOS and from keyboard settings in control panel -windows- )

like image 189
Gabriele Petrioli Avatar answered Nov 11 '22 17:11

Gabriele Petrioli