tabtrap
Trap focus inside an object. Useful for ensuring keyboard accessibility of modal dialogs.
Usage
Tabtrap comes with versions for two environments: a dev module version, and a standalone browser version. There are multiple ways to initialize the trap in both versions.
tabtrap.module.js
The module version should be used in dev environments that are using import/require module patterns. It won't work as a standalone file in the browser.
// es6// non-es6var tabtrap = // initialize with the static .trapAll() method to trap multiple elementstabtrap // initialize with the class (only traps the first element found)'.modal'
tabtrap.browser.js
The browser version can be used directly in the browser as a standalone file. jQuery is optional.
...
Options
Option | Type | Default |
---|---|---|
disableOnEscape |
boolean | false |
tabbableElements |
object | (view source) |
Methods
Tabtrap.trapAll(element[, options])
Tabtrap
You can also place the element or element selector inside the options object:
Tabtrap.trapAll(options)
Tabtrap
The following methods are used with jQuery
.tabtrap('enable')
.tabtrap('disable')
;
.tabtrap('toggle')
// probably don't do this.;