Skip to content
Restricts keyboard tabindex to a single subtree in the DOM. This behaviour is useful when implementing a modal UI
JavaScript
Branch: master
Clone or download

Latest commit

Latest commit b7302e3 Jan 31, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Lasso to Webpack Jan 30, 2020
src Lasso to Webpack Jan 30, 2020
test Lasso to Webpack Jan 30, 2020
.eslintrc Lasso to Webpack Jan 30, 2020
.gitignore Lasso to Webpack Jan 30, 2020
.npmrc first commit Jun 29, 2017
.travis.yml Lasso to Webpack Jan 30, 2020
LICENSE first commit Jun 29, 2017
README.md Lasso to Webpack Jan 30, 2020
babel.config.json Lasso to Webpack Jan 30, 2020
browser.json Fix require-run Jan 31, 2020
index.js Lasso to Webpack Jan 30, 2020
karma.conf.js Lasso to Webpack Jan 30, 2020
package.json 0.2.2 Jan 31, 2020
webpack.docs.js Lasso to Webpack Jan 30, 2020
yarn.lock Lasso to Webpack Jan 30, 2020

README.md

makeup-keyboard-trap

Build Status Coverage Status Dependency status devDependency status

A vanilla JavaScript port of jquery-keyboard-trap.

This module restricts keyboard tabindex to a single subtree in the DOM. This behaviour is useful when implementing a modal interface (e.g. a modal dialog).

It will ignore programmatically focusable items with a tabindex of -1.

Experimental

This CommonJS module is still in an experimental state, until it reaches v1.0.0 you must consider all minor releases as breaking changes. Patch releases may introduce new features, but will be backwards compatible.

const keyboardTrap = require('makeup-keyboard-trap');

// trap an element
keyboardTrap.trap(document.querySelector('el'));

// untrap the current trapped element
keyboardTrap.untrap();

Install

// via npm
npm install makeup-keyboard-trap

// via yarn
yarn add makeup-keyboard-trap

Events

  • keyboardTrap : fired by trapped element when keyboard trap is activated
  • keyboardUntrap : fired by trapped element when keyboard trap is deactivated

Dependencies

CI Build

https://travis-ci.org/makeup-js/makeup-keyboard-trap

Code Coverage

https://coveralls.io/github/makeup-js/makeup-keyboard-trap

You can’t perform that action at this time.