Kitchen Sink
This page includes a wide range of interactive elements to demo OpenKeyNav.
Make sure OpenKeyNav is on. If these commands aren't working, OpenKeyNav might be off. Press Shift + o
to turn OpenKeyNav on/off.
Drag-and-drop Elements (m)
Moveable Items
Drop Targets
Requires Drag Mode
to be configured. See full drag mode configuration options.
const openKeyNav = new OpenKeyNav();
openKeyNav.init({
...
modesConfig: {
move: {
config: [
{
fromElements: '.moveableElement',
toElements: '.dropZoneTargetType1, .dropZoneTargetType2',
callback: (from, to) => {
to.appendChild(from);
},
},
],
},
},
});
Buttons (k)
Links (k)
Semantically coded links are tab
-navigable and can be activated with enter
.
OpenKeyNav enables users to click on links via Click Mode
(k).
Internal link
1. Internal Link<a href="./basic_example">1. Internal Link</a>
External link
2. External Link<a href="https://github.com/LDubya/OpenKeyNav" target="_blank" rel="noopener noreferrer">
2. External Link
</a>
Link without href, tabindex=0
3. Link without an href, tabindex=0<a onclick="alert('Link 3 clicked')" tabindex="0">3. Link without an href, tabindex=0</a>
Inputs and Forms (k)
You can use tab
, arrow keys
, space
, and enter
to interact with form fields.
OpenKeyNav enables users to click on / focus on form fields via Click Mode
(k).
Headings (h)
Heading Level 1 (1)
Heading Level 2 (2)
Heading Level 3 (3)
Heading Level 4 (4)
Heading Level 5 (5)
Heading Level 6 (6)
Scrollable Regions (s)
Scrollable region #1
Line 2
Line 3
Line 4
Line 5
Line 6
Scrollable region #2
Line 2
Line 3
Line 4
Line 5
Line 6
Special cases and gotchas
Link without href
4. Link without an href (not tabbable)<a onclick="alert('Link 4 clicked')">4. Link without an href (not tabbable)</a>
Although OpenKeyNav's Click Mode
can activate a link (<a></a>
) that isn't tabbable, untabbable links create accessibility barriers, are a WCAG violation, and should be remediated.
Many users, including those with motor disabilities or visual impairments, rely on the keyboard (especially the "Tab" key) to navigate web pages. If links cannot be focused by tabbing, these users cannot access the content the links point to.
If you're treating a link (<a></a>
) as a button by handling the click event using Javascript, then to ensure keyboard accessibility you must:
- handle the
enter
keypress the same way you handle a mouse click event, - and either:
- give the link an empty
href
attribute value (<a href="">
) - or give the link a
tabindex
attribute greater than -1, ideally 0 (<a tabindex="0">
).
- give the link an empty
Alternatively, you could just use a <button>
, which does all of this out of the box.