Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Disabling left and right arrow shortcut navigation in Autofocus? WordPress


Both Autofocus and Shadowbox JS photo gallery plugin use left and right arrow keys as navigation hotkeys. Currently, when one hits the left arrow from within a gallery slideshow Autofocus closes the slideshow and navigates to the previous post.

I'd like to either a) prioritize arrow shortcuts for Shadowbox navigation when a gallery is open or b) disable Autofocus arrow shortcuts entirely.

Looking in thematic-functions.php I noticed &larr and &rarr arrows but I'm unsure how to change their hotkey functionality. Suggestions?

Answers (3)


Bill Hunt answers:

Can you post a link? The keycodes for the right and left arrows are 39 and 37 - searching for those numbers in the javascript and commenting out the relevant sections should be enough.

Jim Harris comments:

Jim Harris comments:

This is what worked to kill the page navigation hotkeys:

open theme_folder/js/jquery.hotkeys-0.7.9.min.js

Edit out 37: left , and 39: right,

Save and reupload.

I'd still like to find a way to make slideshow hotkeys override the nav hotkeys while keeping the nav hotkeys working otherwise.


enodekciw answers:

open up this file -> theme_folder/js/afscripts.js
find lines like these:

// Previous Hot Key
jQuery(document).bind('keydown', 'left', function(){
var prevlink = jQuery("#nav-above .nav-previous a").attr("href");
if (!prevlink == '') {
window.location = prevlink;

// Next Hot Key
jQuery(document).bind('keydown', 'right', function(){
var nextlink = jQuery("#nav-above .nav-next a").attr("href");
if (!nextlink == '') {
window.location = nextlink;

get rid of them or comment them out, and reupload that afscripts.js file.

EDIT: as I see @ your link, it works like charm. <- and -> keys only navigates in shadowbox gallery

Jim Harris comments:

I deleted the //Previous Hot Key and //Next Hot Key code and replaced the afscripts.js file with the modified one but no dice - the hotkeys to change between blog posts still override the photo gallery hot keys.

This looks like it's on the right track, however. Do you know of anywhere else I should look for similar Hot Key coding?


Duncan O'Neill answers:

Simple brute force solution:

In your style.css in the autofocus folder, look for the rule .navigation .meta-nav. It's on line 144 in my version, just under the comment heading Navigation, and is empty.

Change it to this;

.navigation .meta-nav {display:none;}


.navigation .meta-nav {visibility:hidden;}

Jim Harris comments:

This hides the floating arrow in AutoFocus+ but leaves the shortcut functionality intact.