LitElement: IronA11yKeysBehavior

Replace IronA11yKeysBehavior with keydown event listener when migrating from PolymerElement to LitElement

Ronny Roeller
NEXT Engineering
1 min readApr 16, 2019

--

The Polymer library provides the IronA11yKeysBehavior for easy handling of keyboard events. For example, the following would trigger the save() method when the user pressed Enter:

As you can’t apply IronA11yKeysBehavior mixin to a LitElement, your element must implement the behavior itself. Luckily, this is as easy as before:

Alternatively, you can bind the handling also directly to a specific element in the template:

Happy coding!

--

--

Ronny Roeller
NEXT Engineering

CTO at nextapp.co # Product discovery platform for high performing teams that bring their customers into every decision