How can I get auto-repeated keydown events in Firefox when arrow keys are held down?

You can use keypress and check the e. KeyCode == 38,40 instead of e. Which or e.

CharCode This is consistent across Mac and Win $('#test'). Bind($.browser. Mozilla?'keypress' : 'keyup', function(e) { if ( (e.

Which || e. KeyCode) == 40 ) { /* doSometing() */ } }) See JavaScript Madness: Keyboard Events (3.2.Values Returned on Character Events) and event. KeyCode on MDC.

You can use keypress and check the e. KeyCode == 38,40 instead of e. Which or e.

CharCode This is consistent across Mac and Win. $('#test'). Bind($.browser.

Mozilla? 'keypress' : 'keyup', function(e) { if ( (e. Which || e.

KeyCode) == 40 ) { /* doSometing() */ } }); See JavaScript Madness: Keyboard Events (3.2. Values Returned on Character Events) and event. KeyCode on MDC.

That same page (which is also my stock key event page to which I refer people) also has "2.2. Events Triggered on Auto-Repeat", which suggests that browser support for auto-repeating keypress events for special keys such as cursor keys is no better than for keydown events. – Tim Down Dec 14 '09 at 22:13 'keydown' for all browsers except firefox (in my case safari) instead of 'keyup' worked fine for me. Thanks!

– pex Dec 15 '09 at 15:06.

Yes, you're kind of stuck. You could emulate the behaviour you want by using timers until you receive the corresponding keyup, but this obviously won't use the user's computer's keyboard repeat settings. The following code uses the above method.

The code you want to handle keydown events (both real and simulated) should go in handleKeyDown: var keyDownTimers = {}; var keyIsDown = {}; var firstKeyRepeatDelay = 1000; var keyRepeatInterval = 100; function handleKeyDown(keyCode) { if (keyCode == 38) { alert("Up"); } } function simpleKeyDown(evt) { evt = evt || window. Event; var keyCode = evt. KeyCode; handleKeyDown(keyCode); } document.

Onkeydown = function(evt) { var timer, fireKeyDown; evt = evt || window. Event; var keyCode = evt. KeyCode; if ( keyIsDownkeyCode ) { // Key is already down, so repeating key events are supported by the browser timer = keyDownTimerskeyCode; if (timer) { window.

ClearTimeout(timer); } keyIsDownkeyCode = true; handleKeyDown(keyCode); // No need for the complicated stuff, so remove it document. Onkeydown = simpleKeyDown; document. Onkeyup = null; } else { // Key is not down, so set up timer fireKeyDown = function() { // Set up next keydown timer keyDownTimerskeyCode = window.

SetTimeout(fireKeyDown, keyRepeatInterval); handleKeyDown(keyCode); }; keyDownTimerskeyCode = window. SetTimeout(fireKeyDown, firstKeyRepeatDelay); keyIsDownkeyCode = true; } }; document. Onkeyup = function(evt) { evt = evt || window.

Event; var keyCode = evt. KeyCode; var timer = keyDownTimerskeyCode; if (timer) { window. ClearTimeout(timer); } keyIsDownkeyCode = false; }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions