android13/external/chromium-trace/catapult/third_party/polymer/components/iron-a11y-keys-behavior
liiir1985 7f62dcda9f initial 2024-06-22 20:45:49 +08:00
..
.github initial 2024-06-22 20:45:49 +08:00
demo initial 2024-06-22 20:45:49 +08:00
test initial 2024-06-22 20:45:49 +08:00
.bower.json initial 2024-06-22 20:45:49 +08:00
.travis.yml initial 2024-06-22 20:45:49 +08:00
CONTRIBUTING.md initial 2024-06-22 20:45:49 +08:00
README.md initial 2024-06-22 20:45:49 +08:00
bower.json initial 2024-06-22 20:45:49 +08:00
index.html initial 2024-06-22 20:45:49 +08:00
iron-a11y-keys-behavior.html initial 2024-06-22 20:45:49 +08:00

README.md

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:

 keyBindings: {
   '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:

 _onKeydown: function(event) {
   console.log(event.detail.combo); // KEY+MODIFIER, e.g. "shift+tab"
   console.log(event.detail.key); // KEY only, e.g. "tab"
   console.log(event.detail.event); // EVENT, e.g. "keydown"
   console.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.