UNPKG

@logo-elements/component-base

Version:

A set of mixins used by Logo Elements which is extended from Vaadin components.

58 lines (52 loc) 1.63 kB
/** * @license * Copyright LOGO YAZILIM SANAYİ VE TİCARET A.Ş. * * Save to the extent permitted by law, you may not use, copy, modify, * distribute or create derivative works of this material or any part * of it without the prior written consent of LOGO YAZILIM SANAYİ VE TİCARET A.Ş. Limited. * Any reproduction of this material must contain this notice. */ import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js'; /** * A mixin that manages keyboard handling. * The mixin subscribes to the keyboard events while an actual implementation * for the event handlers is left to the client (a component or another mixin). * * @polymerMixin */ export const KeyboardMixin = dedupingMixin( (superclass) => class KeyboardMixinClass extends superclass { /** @protected */ ready() { super.ready(); this.addEventListener('keydown', (event) => { this._onKeyDown(event); }); this.addEventListener('keyup', (event) => { this._onKeyUp(event); }); } /** * A handler for the `keydown` event. By default, it does nothing. * Override the method to implement your own behavior. * * @param {KeyboardEvent} _event * @protected */ _onKeyDown(_event) { // To be implemented. } /** * A handler for the `keyup` event. By default, it does nothing. * Override the method to implement your own behavior. * * @param {KeyboardEvent} _event * @protected */ _onKeyUp(_event) { // To be implemented. } } );