Skip to main content
Logo Appt Light

Success Criterion 2.1.2 - Level A

No Keyboard Trap

Ensure users of assistive technologies can't get stuck anywhere in the app. It is especially common that overlays cannot be closed. Many assistive technologies do not support clicking next to an overlay. As a result, the user gets stuck. You must include a close button which assistive technologies can activate.

Impact

  • Users get very frustrated when they get stuck while using an app.

  • For example, in processes, prevent users from getting stuck by repeating actions indefinitely.

Check

“Are there places in the app where you get stuck with assistive technologies?“

We suggest testing with a screen reader and keyboard access.

Solution

Add a close button to all overlay and popups.

Add close button

On Android, you can show a dialog by using AlertDialogBottomSheetDialog or DialogFragment. You should always add a close button by using the setNegativeButton method. The focus of assistive technologies is automatically trapped inside the dialog while it's visible.

val builder = AlertDialog.Builder(this)
builder.setTitle("Confirm Appt membership?")
builder.setMessage("Your bank account will be billed.")

builder.setPositiveButton("Proceed") { dialog, which ->
  // Proceed
}

builder.setNegativeButton("Cancel") { dialog, which ->
  // Cancel
}

builder.show()

Resources

Feedback?

Let us know!