Keyboard navigation for Web Apps and Components.
Loock provides a set of behaviors to manage focus and keyboard navigation for web apps and components.
Organize your web page or web application by navigation areas.
Never lose the context while navigating the area with the TAB key.
Leave the context with the ESC key.
Install via NPM:
npm install @chialab/loock
yarn add @chialab/loock
pnpm add @chialab/loock
Load via esm.run:
import { focusTrapBehavior } from 'https://esm.run/@chialab/loock';import { focusTrapBehavior } from '@chialab/loock';
const dialog = document.getElementById('.dialog');
const trap = focusTrapBehavior(dialog, {
inert: true,
});
dialog.addEventListener('open', () => {
trap.connect();
});Install the dependencies and run the build script:
pnpm install
pnpm build
This will generate the bundles in the dist folder, as well as the declaration files.
Run the test script:
pnpm test
Loock is released under the MIT license.