Success Criterion 2.1.1 - Level A
Keyboard
Ensure that all functionality in the app can be used with assistive technologies. People who are blind use the screen reader. People with a motor disability use switch control, voice control and/or the keyboard. These assistive technologies are built into the operating system.
Impact
People with limited hand function often have difficulty using the touchscreen. Using a keyboard is a solution for them.
People who are blind often use a screen reader to operate apps.
People with motor disabilities often use switch control or voice control to operate an app.
Check
“Can you fully operate the app when using assistive technologies?“
We recommend to test with atleast the screen reader, voice control, keyboard access or switch access.
Solution
All interactive elements must be operable with assistive technologies. It can be needed to move the focus of assistive technologies.
Adjust order for keyboard
On Android, you can use several focus
properties to modify the keyboard focus order.
android:nextFocusForward
: set the next element to move focus to.android:nextFocusUp
: specify which element should receive focus when navigating upandroid:nextFocusDown
: specify which element should receive focus when navigating downandroid:nextFocusLeft
: specify which element should receive focus when navigating to the leftandroid:nextFocusRight
: specify which element should receive focus when navigating to the right
<View
android:id="@+id/notFocusable"
android:focusable="false"/>
<EditText
android:id="@+id/field1"
android:focusable="true"
android:nextFocusForward="@+id/field2"
android:nextFocusDown="@+id/field3"
android:nextFocusRight="@+id/field2"/>
<EditText
android:id="@+id/field2"
android:focusable="true"
android:nextFocusForward="@+id/field3"
android:nextFocusDown="@+id/field4"/>
<EditText
android:id="@+id/field3"
android:focusable="true"
android:nextFocusForward="@+id/field4"/>
<EditText
android:id="@+id/field4"
android:focusable="true"/>
Adjust order for assistive technologies
On Android, you can set the accessibility order in XML, or modify the accessibility order in code. You can use the android:accessibilityTraversalAfter
and android:accessibilityTraversalBefore
properties in XML. Or you can use the setAccessibilityTraversalBefore
and setAccessibilityTraversalAfter
methods in code.
header.setAccessibilityTraversalBefore(R.id.description)
list.setAccessibilityTraversalAfter(R.id.description)
Move accessibility focus
On Android, you can send an AccessibilityEvent
of the type TYPE_VIEW_FOCUSED
to move the focus of assistive technologies to a specific view. The view must be focusable for this event to take effect.
fun focus(view: View) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}