IcarusWorks / ember-key-manager

A service for (un)binding keyboard up and down events.
MIT License
42 stars 11 forks source link

keydown != keydown, need consecutive callback firing #33

Closed gossi closed 6 years ago

gossi commented 6 years ago

In a regular event listener elem.addEventListener('keydown', ....) after a system delay consecutive keydowns will be fired, when the key is hold by the user. At the moment with the macros one and exactly one callback is fired and the consecutive keydown callbacks are missing. Am I doing something wrong?

gossi commented 6 years ago

The handleEvent of key-manager debounces - why? This should be up to the implementation of the callback to do this.

I hacked it that way:

import KeyManagerService from 'ember-key-manager/services/key-manager';

export default KeyManagerService.extend({

    handleEvent(event) {
        const isServiceDestroyed = this.get('isDestroyed') || this.get('isDestroying');

        if (isServiceDestroyed) {
            return false;
        }

        this.set('event', event);
        this._handleEvent();
    }
});

Also affects #34

jordpo commented 6 years ago

So I think the debounce is preventing the callback from getting fired repeatedly. I'll take a look and probably will just take it out all together. @gossi we do want to have the repeated fire be something the app specifies when adding the macro - allowRepeat = true defaults to true.

gossi commented 6 years ago

Sounds great, since repeatedly firing is the default when adding keyevents using standard dom APIs, having it behave like that is great.