Keyboard Shortcuts with x_treme theme

dspguy1

Joined: 2003-01-14
Posts: 45
Posted: Sat, 2010-01-09 22:42

This took me a good hour to research. I could not find a post related to this. If you want to add keyboard shorcuts such as left and right arrow keys to go to previous and next images here are the steps for the x_treme theme:

1. Download shortcut.js and put it in the root of your gallery folder:
http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js
2. Go to your x_treme theme folder (root/themes/x_treme/templates/) and create a local folder.
3. Copy photo.tpl to the local folder.
4. Find the following code:

Quote:
{assign var="nextImage" value=$theme.navigator.next}
{assign var="backImage" value=$theme.navigator.back}

5. Add the following block of code after that (make sure you change 'gallery' to the root of your gallery):

Quote:
<script type="text/javascript" src="/gallery/shortcut.js"></script>

{if !empty ($nextImage)}
<script type="text/javascript" >
shortcut.remove("Right");

shortcut.add("Right", function()
{literal}
{
{/literal}
self.location = "{g->url params=$nextImage.urlParams}"
{literal}
} );
{/literal}
</script>
{/if}

{if !empty ($backImage)}
<script type="text/javascript" >
shortcut.remove("Left");

shortcut.add("Left", function()
{literal}
{
{/literal}
self.location = "{g->url params=$backImage.urlParams}"
{literal}
} );
{/literal}
</script>
{/if}

6. Delete your template cache in the maintenance admin section.

This will work for other themes too, you just have to find the correct template and put the code there.

Hope this helps. Please post if you think anything is wrong with these instructions.
MT