I'm having trouble getting Opera to recognize a repeating key event - I was
wondering if anyone had experience with this.
Basically, I am trying to move a <div> based on the arrow keys that are
pressed - left/right motion as you press the left & right arrow keys. I want
the element to move as long as the key is held down.
The code I'm using is:
function movePaddle(e) {
if (window.event) {
key=event.keyCode;
} else {
key = e.which;
}
if ((key == 37) && (padX > padMinX)) { padX-=5; }
else if ((key == 39) && (padX < padMaxX)) { padX+=5; }
document.getElementById("paddle").style["left"]=padX;
}
And in the body:
<body onKeyDown="javascript:movePaddle(event);">
This works for IE, Netscape, and Firefox, no problems. But Opera won't read
the autorepeat of the key, so it only moves once each time you press the
key.
Any thoughts on a workaround for it?