PolymerElements / iron-a11y-keys

A basic element implementation of iron-a11y-keys-behavior
19 stars 22 forks source link

Binding to specific events (documentation) #28

Closed robrez closed 7 years ago

robrez commented 8 years ago

In iron-a11y-keys-behavior there is some documentation demonstrating how to bind to specific key* events..

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

For me, it took a bit of reading the code to determine that the same syntax can be used in the keys attr..

  <iron-a11y-keys
      keys="space shift+tab enter:keypress esc:keyup"
      on-keys-pressed="_myHandler">
  </iron-a11y-keys>

Is there any opposition to adding an example like the above to docs for iron-a11y-keys?

valdrinkoshi commented 8 years ago

@robrez I would add the keys property jsdoc describing what's the format and expand the "Example" section of the "keys attribute" paragraph with something like:

Each key supports the following format: KEY[+MODIFIER][:TRIGGERING_EVENT] e.g. keys = "space shift+tab enter:keyup alt+ctrl+canc:keypress"

WDYT? Feel free to open a PR if you fee like it :)

robrez commented 8 years ago

That's a good idea. Will try to submit a pr this weekend

robrez commented 8 years ago

Ooos! Accidentally clicked close instead of comment