Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: page-up/down and up/down-arrow keypress events?


Message #1 by "Maurice Faber" <mrdata@i...> on Thu, 21 Jun 2001 15:03:25 +0200
> I read that Netscape?s Javascript 1.2 does not support the keypress 
events
> for the page-up/down and up/down-arrow keys.
> 
> Does anyone know whether this is possible in IE5.5 or NN6?
> 

In IE 5.5, you can trap for those keystrokes, but only in the onkeydown 
event, for some reason.  You'll have to find the key code value for those 
keys (sorry, don't know of the top of my head).  Then, use something like 
this to capture:

LEFT_ARROW = 134; // <-- Find the real code value.

window.document.onkeydown = captureKeys;

function captureKeys() {
	var fAlt	= window.event.altKey;
	var fCtrl	= window.event.ctrlKey;
	var fShift	= window.event.shiftKey;
        var iKey        = window.event.keyCode
	switch case (iKey) {
          case LEFT_ARROW:
              // do something here
              breask;

          case RIGHT_ARROW:
          ...
          case else: return false;
	}
}

Hope this helps.

Cheers,

J

  Return to Index