Hiya! Thanks in advance to anyone willing to help me or even read this!
What I’m trying to do is hotkey items on a long list so that anywhere on the page, the user can push the letter “g” and be taken to the first list item that starts with “g,” and so on.
I found this code on several sites —
[code=php]
<script language=”JavaScript1.2″>
var hotkey=97
var destination=”#target”
if (document.layers)
document.captureEvents(Event.KEYPRESS)
function goitem(e){
if (document.layers){
if (e.which==hotkey)
window.location=destination
}
else if (document.all){
if (event.keyCode==hotkey)
window.location=destination
}
}
document.onkeypress=goitem
</script>
–and have modified it in every way I could think of, but cannot manage to get it set up for multiple keys. Obviously I want to link the “a” key to #A and the “b” key to #B and the “c” key to #C and so on, but I can only ever get a single one to work. I’m clumsy and self-taught with javascript and don’t know if it can even be done. Help would be greatly appreciated!