Forum Moderators: open
@Mike
You need to implement some sort of key listener. The Yahoo UI Library [developer.yahoo.com] has a KeyListener [developer.yahoo.com] class that you could use to capture the key event, and then call whatever function is appropriate. Hope that helps.
<script type="text/javascript">document.onkeydown = function (event) {
var key_code = (event && event.which) ? event.which : window.event.keyCode;
//keys we are looking for, and their corresponding key codes:
// < = 188, > = 190, left arrow = 37, right arrow = 39,
//number pad (4) left arrow = 100, number pad (6) right arrow = 102
var codesToWatchFor = {
"188":"previous",
"190":"next",
"37":"previous",
"39":"next",
"100":"previous",
"102":"next",
"previous":function () { alert("A left arrow key has been pressed"); },
"next":function () { alert("A right arrow key has been pressed"); }
};
if (key_code in codesToWatchFor) { //one of the desired keys listed in comment above has been pressed
var action = codesToWatchFor[key_code];
codesToWatchFor[action](); //invoke either of our codesToWatchFor.previous or codesToWatchFor.next functions
}
};</script>