views:

30

answers:

0

Hello,

I am currently trying to implement keyboard navigation with jQuery (1.4.2) on a webpage that has all the information getting pulled from a ajax request with Spry.

I know it's a convoluted method of grabbing data and populating a webpage with it, but I really like how Spry handles datasets.

My markup looks something like this:

<div class="wrapper detail" spry:repeat="dsPhotos" spry:odd="odd">
  <div class="full-width">
    <div class="cover">
    <span class="outside-boxes counter"><a href="#{ds_RowNumberPlus1}">{ds_RowNumberPlus1}</a></span>
       <span class="outside-boxes topLink"><a href="#top" class="scroll"><img src="../../_images/button-top.gif" width="11" height="19" alt="Top" /></a> </span>
          {photoLink}
  <p>{photoCaption}</p>
   </div>
 </div>
</div><!-- /end .wrapper -->

.wrapper gets repeated for how many items there are in the "dataset" with the Spry framework. {photoLink} is the dynamic content that Spry loads from the dataset.

I want to use jQuery to capture keyboard presses and scroll to the next image. I am using a jQuery plugin http://github.com/BrianTheCoder/jquery-keyboard-navigation.

My problem is I haven't used .live or .delegate before and I'm having trouble how I would write up the syntax and what it would look like.

If someone has a better solution to capture keyboard keys instead of the plugin I'm using people let me know! I'm not awesome with javascript yet.

This is what my jQuery looks like so far:

$.whenPressed('s',function(){ 
 alert('you pressed s');
});