Skip to content

Instantly share code, notes, and snippets.

@atsea
Last active November 2, 2017 01:15
Show Gist options
  • Save atsea/cf259c8487730bc69713164d1a92cc9e to your computer and use it in GitHub Desktop.
Save atsea/cf259c8487730bc69713164d1a92cc9e to your computer and use it in GitHub Desktop.
ARIA accessibile keyboard script allows disabled users to navigate the page left, right, up or down.
/**
* SOCIAL SHARING TOOL BAR ARIA
* @type {[type]}
* @see https://dequeuniversity.com/library/aria/content-feedback/sf-social-toolbar
*/
var $toolbar = $('#social-toolbar');
var $items = $toolbar.find('li');
$toolbar.on('keydown', '.button', function (e) {
var which = e.which;
var target = e.target;
if (which === 37 || which === 38) { // LEFT |or| UP
focusAdjacentItem(target, which, $items);
} else if (which === 39 || which === 40) { // RIGHT |or| DOWN
focusAdjacentItem(target, which, $items);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment