• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2<!---
3
4This README is automatically generated from the comments in these files:
5iron-a11y-keys-behavior.html
6
7Edit those files, and our readme bot will duplicate them over here!
8Edit this file, and the bot will squash your changes :)
9
10The bot does some handling of markdown. Please file a bug if it does the wrong
11thing! https://github.com/PolymerLabs/tedium/issues
12
13-->
14
15[![Build status](https://travis-ci.org/PolymerElements/iron-a11y-keys-behavior.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-a11y-keys-behavior)
16
17_[Demo and API docs](https://elements.polymer-project.org/elements/iron-a11y-keys-behavior)_
18
19
20##Polymer.IronA11yKeysBehavior
21
22`Polymer.IronA11yKeysBehavior` provides a normalized interface for processing
23keyboard commands that pertain to [WAI-ARIA best practices](http://www.w3.org/TR/wai-aria-practices/#kbd_general_binding).
24The element takes care of browser differences with respect to Keyboard events
25and uses an expressive syntax to filter key presses.
26
27Use the `keyBindings` prototype property to express what combination of keys
28will trigger the callback. A key binding has the format
29`"KEY+MODIFIER:EVENT": "callback"` (`"KEY": "callback"` or
30`"KEY:EVENT": "callback"` are valid as well). Some examples:
31
32```javascript
33 keyBindings: {
34   'space': '_onKeydown', // same as 'space:keydown'
35   'shift+tab': '_onKeydown',
36   'enter:keypress': '_onKeypress',
37   'esc:keyup': '_onKeyup'
38 }
39```
40
41The callback will receive with an event containing the following information in `event.detail`:
42
43```javascript
44 _onKeydown: function(event) {
45   console.log(event.detail.combo); // KEY+MODIFIER, e.g. "shift+tab"
46   console.log(event.detail.key); // KEY only, e.g. "tab"
47   console.log(event.detail.event); // EVENT, e.g. "keydown"
48   console.log(event.detail.keyboardEvent); // the original KeyboardEvent
49 }
50```
51
52Use the `keyEventTarget` attribute to set up event handlers on a specific
53node.
54
55See the [demo source code](https://github.com/PolymerElements/iron-a11y-keys-behavior/blob/master/demo/x-key-aware.html)
56for an example.
57
58
59