Child pages
  • Tutorial - Keyboard Accessibility Plugin

Documentation for a historical release of Infusion: 1.3
Please view the Infusion Documentation site for the latest documentation.
If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

This tutorial is incomplete. Any information here should be considered to be incorrect until this warning is remove.

The Fluid library includes a jQuery Keyboard Accessibility (a11y) plugin. This plugin allows developers to add keyboard handlers to their code without a lot of extra overhead. This tutorial will walk the reader through an example of using the plugin.

This tutorial assumes that:

  • you are already familiar with HTML, Javascript and CSS
  • you are basically familiar with what the Keyboard Accessibility Plugin is and does
  • now you just want to know how to use it.

For technical API documentation, see Keyboard Accessibility Plugin API.

Tutorial: How to Use the Keyboard Accessibility Plugin


Let's say you are creating a set of tabs using an unordered list. This tutorial will show you how to use the jQuery Keyboard Accessibility Plugin to ensure that your tabs can be used with the keyboard.

There are four basic steps to adding Keyboard Accessibility to your application:

  • Setup: Download and install the Fluid Infusion library
  • Step 1: Prepare your markup
  • Step 2: Write the script
  • Step 3: Add the script to your HTML
  • Step 4: Apply styles

The rest of this tutorial will explain each of these steps in detail.

On This Page
Still need help?

Join the fluid-talk mailing list and ask your questions there.

Setup: Download and install the Fluid Infusion library

  1. Download a copy of the Fluid Infusion component library from:
  2. Unpack the zip file you just downloaded, and place the resulting folder somewhere convenient for your development purposes.
    The folder will have the release number in it's name (e.g. infusion-1.0/). The rest of this tutorial will use infusion-1.0 in its examples, but if you downloaded a different version, you'll have to adjust.

Step 1: Prepare the required files

You'll need to create a file, say initalize.js, to contain your code - the script you write to apply keyboard a11y to your tabs.
If you use the InfusionAll file, then your <head> might look like:

<script type="text/javascript" src="infusion-1.0/InfusionAll.js"></script>
<script type="text/javascript" src="initialize.js"></script>

NOTE that the InfusionAll.js file is minified - all of the whitespace has been removed, so it isn't really human-readable.

If you want to be able to debug the code, you'll want to include each of the required files individually. This would look like this:

<script type="text/javascript" src="lib/jquery/core/js/jquery.js"></script>
<script type="text/javascript" src="infusion-1.0/framework/core/js/jquery.keyboard-a11y.js"></script>

Step 2: Prepare your markup

Let's say you want to make some keyboard accessible tabs. The markup might look like this (with FSS to give us a quick tab appearance):

<body class="fl-theme-mist">

        <!-- Code for the tabs -->
        <ul id="tabs" class="fl-tabs">
          <li class="fl-tabs-active"><a href="#catsPanel">Cats</a></li>
          <li><a href="#dogsPanel">Dogs</a></li>
          <li><a href="#hamstersPanel">Hamsters</a></li>
          <li><a href="#alligatorsPanel">Alligators</a></li>

        <!-- Code for the tab content panels -->
        <div id="panels">
            <div id="catsPanel">Cats <a href="">meow</a>.</div>
            <div id="dogsPanel">Dogs <a href="">bark</a>.</div>
            <div id="hamstersPanel">Hamsters <a href="">wheel</a>.</div>
            <div id="alligatorsPanel">Alligators <a href="">bite</a>.</div>

then in a browser window, this might look something like this:

That's all - these are the only changes you need to make to your HTML.

Step 3: Create your script

Remember that initalize.js file we prepared before? We'll use that file to contain your initialization script - the script you write to apply keyboard a11y to your tabs.

In this file, write a function that enables the list items to be selectable with the arrow keys, and show/hide the appropriate panel:

    var tabs = $("#tabs");
    tabs.fluid("selectable", {
        selectableSelector : 'li',
        direction: fluid.a11y.orientation.HORIZONTAL,
        onUnselect: function(el){
            // hide the panel we're leaving....
        onSelect : function(el){
            // ...and show the panel we're entering

This }} function says "once the DOM is ready to be traversed, make all the {{<LI> elements within the #tabs container selectable with the left and right arrow keys.

selectableSelector could be any selector, but for the purposes of this tutorial we're interested in the list items themselves.

That's it! That's all you need to do to add keyboard functionality to your document.

Since there is no visual cues for keyboard accesssibility, it's important to understand that you need to create those cues to know what is selected and where. In CSS, the most basic approach is to take advantage of the outline border-esque feature, added by default in FSS

Important note

The styles in the example below are just that: examples. You are free to create whatever styles you like <...>. The important thing to understand is

  • what the interesting moments are, and
  • what the names of the styles for those moments are
  • No labels