1.4.1 • Published 4 years ago

keynav-web v1.4.1

Weekly downloads
30
License
ISC
Repository
github
Last release
4 years ago

keynav-web

Utility classes to add Keyboard Navigation and Hotkeys for web based UIs.

TODO IE11 support using babel (probably not)

Publish

Build and Test locally

npm install
npm run build
// Load test/keynav.html or test/hotkeys.html in Browser and try it out

Publish NPM Module

// Remember to bump package.json version semantically
npm run build
npm login
npm publish

Keynav Modules/Components

Keyanv

Adds Keyboard navigation to a list of elements with default behavior similar to a native HTML SELECT element. See test/keynav.html for more info.

Example:

// JS
const keynav = new KeynavWeb.Keynav({
    listEl: document.querySelector('.keynav-list'),
    listItemsSelector: '.keynav-list > li',
});
// HTML
<ol class="keynav-list" ...
    <li>List Item A</li>
    <li>List Item B</li>
</ol>

Hotkeys

Adds Hotkeys using data-attributest on an element. Once that element is keyed whatever behavior you added to it is triggered. See test/hotkeys.html for more info.

Example:

// JS
const globalHotkeys = KeynavWeb.Hotkeys.buildGlobal({
    selectorHotkeys: '[data-knw-hotkeys-key]'       // selector can be an attribute or class
});
// HTML
<button data-knw-hotkeys-key='a'>Key a</button>     <!--keying 'a' would click the button -->
<button data-knw-hotkeys-key='b'>Key b</button>

Focus Trap

Traps tabbing withing an element. So you can tab forward or shift+tab on any focussable item within the element BUT not outside it. This is probably only useful in modal dialogs or similar and probably used alongside with Hotkeys. See test/hotkeys.html for more info.

Example:

// JS
const focusTrap = new KeynavWeb.FocusTrap({     // e.g. when opening the dialog
    containerEl: document.querySelector('.my-dialog')
});
focusTrap.remove();     // e.g. when closing the dialog
1.4.1

4 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.2.0

4 years ago

1.3.0

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.22

5 years ago

1.0.23

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.9

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.8

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago