PolymerElements/iron-a11y-keys-behavior

Name: iron-a11y-keys-behavior

Owner: PolymerElements

Description: A behavior that enables keybindings for greater a11y

Created: 2015-05-05 18:53:47.0

Updated: 2018-04-26 19:03:20.0

Pushed: 2018-05-23 02:26:38.0

Homepage:

Size: 1549

Language: HTML

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build status

Demo and API docs

Polymer.IronA11yKeysBehavior

Polymer.IronA11yKeysBehavior provides a normalized interface for processing keyboard commands that pertain to WAI-ARIA best practices. The element takes care of browser differences with respect to Keyboard events and uses an expressive syntax to filter key presses.

Use the keyBindings prototype property to express what combination of keys will trigger the callback. A key binding has the format "KEY+MODIFIER:EVENT": "callback" ("KEY": "callback" or "KEY:EVENT": "callback" are valid as well). Some examples:

Bindings: {
space': '_onKeydown', // same as 'space:keydown'
shift+tab': '_onKeydown',
enter:keypress': '_onKeypress',
esc:keyup': '_onKeyup'

The callback will receive with an event containing the following information in event.detail:

Keydown: function(event) {
onsole.log(event.detail.combo); // KEY+MODIFIER, e.g. "shift+tab"
onsole.log(event.detail.key); // KEY only, e.g. "tab"
onsole.log(event.detail.event); // EVENT, e.g. "keydown"
onsole.log(event.detail.keyboardEvent); // the original KeyboardEvent

Use the keyEventTarget attribute to set up event handlers on a specific node.

See the demo source code for an example.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.