Generate, London September 2017
Software that translates on-screen content into synthetic speech
Windows screen readers create a virtual copy of the browser contents
Windows screen readers pass keys straight through to the browser
<label for="this">Bold</label>
< type="checkbox" id="this" checked>
Define how role, state, properties, and keyboard focus for native elements are handled in the browser
Browsers may support an element, but not accessibility support it
A browser may accessibility support an element, but a screen reader may not
When native accessibility information is unavailable
Use native HTML whenever possible
<button>Tequila!</button>
var button = document.getElementById('button');
button.addEventListener('click', doSomething, false);
When repurposing elements like <div>
and <span>
<span id="button">Tequila!</span>
<span id="button" role="button" tabindex="0">Tequila!</span>
<button role="heading" aria-level="1">Tequila!</button>
When you create custom components it's your responsibility to make it work with the keyboard
<a href="#here" id="button" role="button">Tequila!</a>
var button = document.getElementById('button');
button.addEventListener('keydown', function(event) {
if (event.keyCode == 13) {
doSomething();
}
});
<span id="button" role="button" tabindex="0">Tequila!</span>
var button = document.getElementById('button');
button.addEventListener('keydown', function(event) {
if (event.keyCode == 13 || event.keyCode == 32) {
toggle();
}
});
<body role="application">...</body>
Removes the screen reader from the keyboard intercept chain
Many ARIA roles trigger applications mode automatically, including:
Listen for keydown and capture keycodes:
Experimental JavaScript API that enables developers to modify the accessibility tree
Has landed in Chrome Canary behind the flag:
--enable-blink-features=AccessibilityObjectModel
<span id="button">Tequila!</span>
<div id="container">
Makes me happy!
</div>
var button = document.getElementById('button');
var container = document.getElementById('container');
button.setAttribute('tabindex', 0);
container.setAttribute('hidden', true);
button.accessibleNode.role = "button";
button.accessibleNode.expanded = false;
var content = new AccessibleNodeList();
content.add(container.accessibleNode);
function disclose(event) {
if(container.getAttribute('hidden')) {
button.accessibleNode.expanded = true;
button.accessibleNode.controls = content;
container.removeAttribute('hidden');
}
else {
button.accessibleNode.expanded = false;
button.accessibleNode.controls = null;
container.setAttribute('hidden', true);
}
}
button.addEventListener('click', disclose, false);
button.addEventListener('keydown', function(event) {
if (event.keyCode == 13 || event.keyCode ==32) {
disclose();
}
});
Thank you