Div Positioning + Other stuff

From: ANT_THOMAS28 Oct 2010 15:04
To: ALL7 of 8

May as well keep it in the same thread because it's more stuff about my gallery.

 

I'm fairly happy with how it looks and works but one thing I'd love it to do it be able to go to next and previous photos like you can with Facebook and Lightbox galleries, as well as many others online, by pressing the right and left cursor keys.

 

I've been searching for hours now trying to figure it out. Looking at onkeypress, onkeyup, onkeydown but can't figure out how to get anything in a workable form.

 

The next and previous links are generated by PHP so it just needs to be able to replicate those.

From: af (CAER)28 Oct 2010 15:47
To: ANT_THOMAS 8 of 8
A quick search suggests keyboard event detection is a bitch.
However, this page offers some clues.
javascript code:
 
var keyDown = function(e) {
    var evt = e || window.event;
    switch (evt.keyCode) {
        case 37: { // left arrow key
            window.location = URL_FOR_NEXT_PAGE;
        }
        case 39: { // right arrow key
            window.location = URL_FOR_PREV_PAGE;
        }
    }
    return document.defaultAction; // might not be needed
    // (I use jQuery which makes a lot of this stuff easier)
}; // keyDown()
 
// I dunno where you'd put this bit - <body onload="..."> maybe?
document.onkeydown = keyDown;
 
EDITED: 28 Oct 2010 15:49 by CAER