home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 November
/
Chip_2004-11_cd1.bin
/
zkuste
/
jalbum
/
ukazka
/
res
/
js
/
keyboard.js
< prev
next >
Wrap
Text File
|
2004-01-12
|
2KB
|
84 lines
/*
************************************************************
Keyboard support
Keys:
RIGHT Arrow : Next page
LEFT Arrow : Previous page
Page UP : Index page
HOME : First page
END : Last page
S,s : Toggle start/stop slide show (not in index)
I,i : Toggle exif info (not in index)
Tested on: IE6, Mozilla 1.4, Netscape 7.1, Opera 7.2
Bugs:
- HOME,END doesn't work in Opera
************************************************************
*/
var takenAction = false;
//IE&Gecko Code
function IEGeckoKeyPress(oEvent)
{
if (!oEvent) var oEvent = window.event;
if (oEvent.keyCode) myKeyCode = oEvent.keyCode;
else if (oEvent.which) myKeyCode = oEvent.which;
if (oEvent.repeat || takenAction) { return; }
if (myKeyCode >= 16 && myKeyCode <= 18) { return; }
if (oEvent.shiftKey) { myKeyCode += 1000; }
if (oEvent.ctrlKey) { myKeyCode += 2000; }
if (oEvent.altKey) { myKeyCode += 4000; }
//alert(oEvent.type + "=" + myKeyCode);
myKeyPress(myKeyCode);
}
function myKeyPress(myKeyCode)
{
switch (myKeyCode)
{
case 39: // RIGHT arrow
case 107: // NUM +
takenAction = true;
nextPage();
break;
case 37: // LEFT arrow
case 109: // NUM -
takenAction = true;
prevPage();
break;
case 33: // Page UP
takenAction = true;
indexPage();
break;
case 36: // HOME
takenAction = true;
firstPage();
break;
case 35: // END
takenAction = true;
lastPage();
break;
case 83: // S,s
if ( isSlideShow )
{
// Only if i have slide show
takenAction = true;
navSlideShow();
}
break;
case 73: // I,i
takenAction = true;
navToggleInfo();
break;
default:
//alert(oEvent.type + "=" + myKeyCode);
break;
}
}
function initKeyboard()
{
document.onkeydown = IEGeckoKeyPress;
}