messages = array(); $this->fields = array( 'previous' => __("Previous [Left arrow]", 'keyboard-navigation'), 'next' => __("Next [Right arrow]", 'keyboard-navigation'), 'first' => __("First [Shift-Left arrow]", 'keyboard-navigation'), 'last' => __("Last [Shift-Right arrow]", 'keyboard-navigation'), ); if (isset($_POST['action'])) { if ($_POST['action'] == "update-fields") { $any_updated = false; foreach (array_keys($this->fields) as $field) { if (isset($_POST["selector-${field}"])) { update_option("keyboard-navigation-selector-${field}", $_POST["selector-${field}"]); $any_updated = true; } } update_option("keyboard-navigation-highlight-selected-elements", ($_POST['highlight-selected-elements'] ? "1" : "0")); if ($any_updated) { $this->messages[] = "Selectors updated."; } } } } function footer() { $plugin_url_root = pathfinding_get_admin_url() . '/' . pathfinding_get_plugin_path(); ?>
Keyboard Navigation Version 0.1
Copyright © 2008 John Bintz | Released under the GNU GPL
Need some sane defaults for your theme? Click one of the links below to populate the selectors on the left:
Are you a theme author? Send your theme's navigation defaults to John Bintz and get them included!
Keyboard Navigation uses CSS3 Selectors to find the hyperlinks on the page that define the previous and next links on the page, and then uses JavaScript to assign the act of hitting the left and right arrow keys on the keyboard to clicking those links. This is exactly the same approach that you would use to style a specific element on the page:
Targeting the <a href="next-page"> on this page is quite easy — provide the CSS selector for the id of the element:
a#next-link
If the <a href> does not have an id, but does have a class, or is the only child of a particular element, you can use syntax like:
div.nav div#next-link-holder a
Keyboard Navigation extends this slightly so that, if the target element is not a <a href> tag, Keyboard Navigation will move up through the tree from the found element until an <a href> is found:
You have two approaches for identifying the <a href="next-page"> tag:
nth-child
:
div#menunav a:nth-child(2)
div#menunav a span.next
Keyboard Navigation requires that the visitor have JavaScript enabled. This plugin uses the Prototype JavaScript library, and including it will increase the size of your total site download.