HighDots Forums  

Can JS use the R/L arrow keys?

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Can JS use the R/L arrow keys? in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Canbeara
 
Posts: n/a

Default Can JS use the R/L arrow keys? - 11-26-2004 , 03:07 AM






I am designing an HTML gallery to display a friend's photos. The gallery
generating software I use implants a "next" and "previous" link in each
photo page. Is there any way I could tap the R/L arrow keys with javascript
to fire an onclick event for the PREV/NEXT links that would make it easier
for keyboard enthusiasts to view the photos?

thanks for any help..

Trish



Reply With Quote
  #2  
Old   
Ulrik Skovenborg
 
Posts: n/a

Default Re: Can JS use the R/L arrow keys? - 12-10-2004 , 09:35 PM






Canbeara wrote:
Quote:
Is there any way I could tap the R/L arrow keys with javascript
to fire an onclick event for the PREV/NEXT links that would make it easier
for keyboard enthusiasts to view the photos?
You could use the onkeydown-event to determine when you hit the Left or
Right-key:
<script type="text/javascript">
document.onkeydown = function(e) {
// Right = 39
// Left = 37
e = (typeof e == "undefined") ? event : e;
b = (typeof e.which == "number") ? e.which : e.keyCode;
if (b == 39) {location.href = document.getElementById("next").href}
else if (b == 37) {location.href =
document.getElementById("prev").href}

}
</script>
</head>
<body>
<a href="prev.html" id="prev">Prev</a> - <a href="next.html"
id="next">Next</a>

You might want to change location.href = document.getEl.... Instead you
could call a function which you use in you gallery or whatever. This is
only an example and I hope you can find out how to implement it yourself.

Skovenborg


Reply With Quote
  #3  
Old   
Canbeara
 
Posts: n/a

Default Re: Can JS use the R/L arrow keys? - 12-11-2004 , 08:32 PM



Thanks very much, Ulrik.
You are exactly the kind of person that I would hire to do design.
Let me know where I can reach you, if you have email.


(you can send to me at php_bb
at telus dot net > remove _)




"Ulrik Skovenborg" <skovenborg (AT) frac (DOT) dk> wrote

Quote:
Canbeara wrote:
Is there any way I could tap the R/L arrow keys with javascript
to fire an onclick event for the PREV/NEXT links that would make it
easier for keyboard enthusiasts to view the photos?



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.