The code for Handling the keyboard button press etc is shown below
**********************##***********************
document.onkeydown = keyHit;
var thisPic = 0;
function keyHit(evt) {
var myPix = new Array("List down your images here (ex. "images/callisto.jpg", "images/callisto123.jpg")");
var imgCt = myPix.length-1;
var ltArrow = 37;
var rtArrow = 39;
var thisKey;
if (evt) {
thisKey = evt.which;
}
else {
thisKey = window.event.keyCode;
}
if (thisKey == ltArrow) {
chgSlide(-1);
}
else {
if (thisKey == rtArrow) {
chgSlide(1);
}
}
return false;
function chgSlide(direction) {
thisPic = thisPic + direction;
if (thisPic > imgCt) {
thisPic = 0;
}
if (thisPic < 0) { thisPic = imgCt; } document.getElementById("myPicture").src = myPix[thisPic]; } }
Just check the code and use it. for any queries mail me.
Edited by Roger, 01 January 2011 - 06:07 PM.


Sign In
Create Account

Back to top









