Skip to main content
Logo Appt Light

Success Criterion 2.1.2 - Level A

No Keyboard Trap

Ensure users of the keyboard interface do not get stuck. Users might not be able to close pop-ups, menus and overlays. Many assistive technologies do not support clicking next to an element. 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!