Keyboard and Interaction Accessibility Techniques

42
Keyboard and Interaction Accessibility Techniques Jared Smith http://webaim.org @webaim

description

Techniques for addressing keyboard accessibility issues for screen reader users and sighted keyboard users.

Transcript of Keyboard and Interaction Accessibility Techniques

Page 1: Keyboard and Interaction Accessibility Techniques

Keyboard and Interaction Accessibi l ity Techniques

Jared Smithhttp://webaim.org

@webaim

Page 2: Keyboard and Interaction Accessibility Techniques

Keyboard User!=

Screen Reader User

Page 3: Keyboard and Interaction Accessibility Techniques

Screen Reader User(usually) =

Keyboard User

Page 4: Keyboard and Interaction Accessibility Techniques

Keyboard Accessibi l ity Testing

Page 5: Keyboard and Interaction Accessibility Techniques

+

Page 6: Keyboard and Interaction Accessibility Techniques
Page 7: Keyboard and Interaction Accessibility Techniques

Keyboard Accessibi l ity is Different When a

Screen Reader is Running

Page 8: Keyboard and Interaction Accessibility Techniques

Source Code Order=

Navigation Order

and screen reader reading order too!

Page 9: Keyboard and Interaction Accessibility Techniques

Navigation Order

• Use CSS (float, position, etc.) to control positioning

• Navigation order should follow visual flow

• Sidebars before or after main content?

• Be careful with “content first” approach

• Design reading/navigation order early

Page 10: Keyboard and Interaction Accessibility Techniques

Screen Reader Navigation

• Links and form controls

• Headings

• Landmarks

• Lists

• Forms

• Buttons

• etc.

Page 11: Keyboard and Interaction Accessibility Techniques

Standard Browser Navigation

• Links and form controls

Page 12: Keyboard and Interaction Accessibility Techniques

Do not remove the focus indicators from links

a { outline:0;}

Page 13: Keyboard and Interaction Accessibility Techniques

“Skip” links“Skip to main content” or

“Skip navigation”???

<a href=”#maincontent”>Skip to main content</a>

<a name=”maincontent” id=”maincontent”></a>

or<div id=”maincontent”>...

Page 14: Keyboard and Interaction Accessibility Techniques

Hidden “Skip” linksa#skip {

position:absolute;left:-10000px;

top:auto;width:1px;height:1px;

overflow:hidden;}

a#skip:focus {position:static;

width:auto;height:auto;

}

Don't display:none the 'skip' link.

Page 15: Keyboard and Interaction Accessibility Techniques

CSS3 to enhance visibilitya#skip { position: absolute; top:-42px; left:0px; background:transparent; transition: top .7s .5s ease-out, background .7s linear;}

a#skip:focus { top:0px; background:#860000; transition: top .1s ease-in, background .25s linear;}

http://webaim.org/presentations/2012/ariahtml5/hiddenlinks2

Page 16: Keyboard and Interaction Accessibility Techniques

ARIA Landmark Roles

• application, banner, complementary, contentinfo, main, navigation, form, and search

• Allows easy access to major page components

• The end of "skip" links? What about sighted keyboard users?

Page 17: Keyboard and Interaction Accessibility Techniques

Landmark Roles

<div role="navigation" aria-label="Main navigation">

<div role="main">

<form role="search">

You can add aria-label to differentiate multiple landmarks of the same type.

Page 18: Keyboard and Interaction Accessibility Techniques

HTML5 and Landmark Roles Mapping

<main> - role="main"<article> - role="article"

<footer> - role="contentinfo"<header> - role="banner"<nav> - role="navigation"

<aside> - role="complementary"

ARIA Support > HTML5 Supportso use both... for now

<main role="main">

Page 19: Keyboard and Interaction Accessibility Techniques

Ensure Interactive Elements are Links or Form Controls

or...

make non-focusable elements focusable with tabindex

Page 20: Keyboard and Interaction Accessibility Techniques

Avoid Tabindex!!!

... unless you're sure you know what you're doing.

If the default tab order is not logical,fix your source code order.

Page 21: Keyboard and Interaction Accessibility Techniques

tabindex="1+" defines an explicit tab order

tabindex="0" allows things besides links and form elements to receive keyboard focus.

tabindex="-1" allows things besides links and form elements to receive programmatic focus

(by scripting, links, etc.)

Page 22: Keyboard and Interaction Accessibility Techniques

<p tabindex=”0” onclick=”submitForm()”>Submit Search</p>

Page 23: Keyboard and Interaction Accessibility Techniques

But

<input type=”submit” value=”Submit Search”>

or

<button onclick=”submitForm()”>Submit Search</button>

are better!

Page 24: Keyboard and Interaction Accessibility Techniques

WARNING!

Click events do not always trigger via keyboard for things other than links or form controls...

... even with tabindex=”0”

Page 25: Keyboard and Interaction Accessibility Techniques

if(event.keyCode==13 || event.keyCode==32){ doStuff();}

Attach an onkeyup event and then check for Enter (13) and Space (32) key presses:

Page 26: Keyboard and Interaction Accessibility Techniques

• Allows non-focusable elements to receive programmatic focus (by scripting, links, etc.)

• Necessary for focusing dialog boxes, error messages, etc.

• WARNING: This removes the element from the default tab order.

tabindex=”-1”

Page 27: Keyboard and Interaction Accessibility Techniques

Review

• Ensure all interactive elements are links or form controls, or make them focusable with tabindex=”0”.

• If using tabindex, detect Enter and Space key events.

• Ensure non-focusable elements (such as dialog windows) have tabindex=”-1” before focusing them programmatically.

Page 28: Keyboard and Interaction Accessibility Techniques

Roving tabindex• Useful for controlling focus within interactive

widgets (menus, tab panels, tree widgets, etc.)

• Set tabindex=”0” on currently active item. This places it in the tab order.

• Set tabindex=”-1” on all other items. This removes them from the tab order and makes them focusable with scripting.

• Use focus() to set focus as user navigates (arrow keys, etc.)

• tabindex=”0” roves or follows the active item allowing users to return directly to it later.

Page 29: Keyboard and Interaction Accessibility Techniques

http://hanshillen.github.io/jqtest/#goto_tabs

Page 30: Keyboard and Interaction Accessibility Techniques

In an ARIA tab panel, the entire tab group functions as one tab stop, then arrow keys are used to select the active tab.

1

3

2

Page 31: Keyboard and Interaction Accessibility Techniques

tabindex=0 tabindex=-1

Page 32: Keyboard and Interaction Accessibility Techniques

tabindex=0

tabindex=-1 tabindex=-1

Press to select the next tab

Page 33: Keyboard and Interaction Accessibility Techniques

tabindex=0

If you tab away from the tab panel and later return, “Cats” remains the active and focused tab because it has tabindex=0.

Page 34: Keyboard and Interaction Accessibility Techniques

Carousels

http://shouldiuseacarousel.com/

Page 35: Keyboard and Interaction Accessibility Techniques

Carousels

http://shouldiuseacarousel.com/

Page 36: Keyboard and Interaction Accessibility Techniques

Carousels

• The target was the biggest item on the homepage - the first carousel item. “Nonetheless, the user failed the task.” - Nielsen Norman Group

• “We have tested rotating offers many times and have found it to be a poor way of presenting home page content.” - Wider Funnel

• 1% clicked a feature. Of those, 89% were the first position. 1% of clicks for the most significant object on the home page? - Notre Dame University

Page 37: Keyboard and Interaction Accessibility Techniques

Carousels• “Almost all of the testing I’ve managed has proven

content delivered via carousels to be missed by users. Few interact with them.” - Adam Fellows

• “Carousels are effective at being able to tell people in Marketing/Senior Management that their latest idea is now on the Home Page. In summary, use them to put content that users will ignore on your Home Page. Or, if you prefer, don’t use them. Ever.” - Lee Duddell

• “Carousels are this decade’s <blink> tag.” - Jared Smith

Page 38: Keyboard and Interaction Accessibility Techniques

Carousels

• http://conversionxl.com/dont-use-automatic-image-sliders-or-carousels-ignore-the-fad/

• http://www.nngroup.com/articles/auto-forwarding/

• http://weedygarden.net/2013/07/carousel-interaction-stats/

• http://bradfrostweb.com/blog/post/carousels/

• http://www.uofadmissionsmarketing.com/2013/02/using-carousels-in-higher-education.html

Page 39: Keyboard and Interaction Accessibility Techniques

Carousel Accessibility Issues

• Automated carousels violate WCAG 2.0 Success Criteria 2.2.2. - Pause, Stop, Hide

• Distracting and confusing

• Difficult interaction model

• No relationship between controls and content

• Loss of focus when carousel changes

Page 40: Keyboard and Interaction Accessibility Techniques

Carousel Accessibility Solutions

• Avoid auto-playing (optimal) or include a visible pause button (preferably) before the carousel

• Pause carousel on mouse hover and on keyboard focus.

• Ensure appropriate alternative text.• Provide context for controls

• Descriptive text• ARIA tab panel?

• Ensure focused or activated items do not disappear, or set focus when they do

Page 41: Keyboard and Interaction Accessibility Techniques

ARIA Design Patterns for Widget Interaction

http://www.w3.org/WAI/PF/aria-practices/#aria_ex

Page 42: Keyboard and Interaction Accessibility Techniques

Questions?

Jared Smithhttp://webaim.org

@webaim