Keyboard Trap

screenshot of modal dialog
Figure 1 : Example of modal dialog where keyboard trap is essential

Keyboard-only users navigate a website using only a keyboard. When their focus gets trapped on an element, a keyboard trap occurs. Due to this, they are unable to navigate forward/backward on the page.

Another example of keyboard trap is when a modal dialog appears on a page and the user is unable to dismiss it using keyboard. One way of ensuring that keyboard trap does not occur is to manage scripts.

NOTE:

  • New to accessibility or uncertain of requirements, it will be helpful to review all sections below.
  • Already familiar with requirements, skip to the “Working Example” section for sample HTML, CSS and JavaScript (when needed), along with a working demo.