...

View Full Version : prevent arraw key scrolling in IE?



anotherJEK
10-04-2012, 08:11 PM
I have an app that registers event handlers for keydown and looks for keyCode for arrow keys on keyboard. The problem is that the default action is to scroll the window if there is overflow. This is not necessary or useful in this application, and is a distraction.

How do I use returnValue to prevent this default action?
Or do I also need cancelBubble = true?



else if(document.attachEvent)
{
document.attachEvent('onkeydown', function() { if(OBJ.gameOn) OBJ.keySwap(window.event, OBJ); });
window.event.returnValue = false; //// this does not seem to do it.
window.event.cancelBubble = true; //// nor this
}


Thank you for time and attention.

anotherJEK
10-04-2012, 08:55 PM
this works:



else if(document.attachEvent)
{
document.attachEvent('onkeydown', function() { if(OBJ.gameOn) OBJ.keySwap(window.event, OBJ); window.event.cancelBubble = true; window.event.returnValue = false;} );
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum