Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Significant lag when typing in inputs #124

Open
ptoro opened this issue Feb 4, 2020 · 0 comments
Open

Significant lag when typing in inputs #124

ptoro opened this issue Feb 4, 2020 · 0 comments

Comments

@ptoro
Copy link

ptoro commented Feb 4, 2020

When typing in inputs, there is no lag if I type slowly but as soon as I start typing quickly, the lag gets so bad that characters don't show on the screen and then all appear at once about three seconds after I finish typing.

This happens whenever I add one or more hotkeys but doesn't happen if I only import the library and service without adding a hotkey.

Looking into the underlying library (mousetrap), I registered one hotkey (ctrl+right arrow), pressed a single quick keypress in an HTML input (I tapped "j" once), and saw the following function calls in the mousetrap library:

_handleKeyEvent
_characterFromEvent
_eventModifiers
Mousetrap.prototype.handleKey
self._handleKey
_getMatches
_handleKeyEvent
_characterFromEvent
_eventModifiers
Mousetrap.prototype.handleKey
self._handleKey
_getMatches
_handleKeyEvent
_characterFromEvent
_eventModifiers
Mousetrap.prototype.handleKey
self._handleKey
_getMatches
_handleKeyEvent
_characterFromEvent
_eventModifiers
Mousetrap.prototype.handleKey
self._handleKey
_getMatches
_handleKeyEvent
_characterFromEvent
_eventModifiers
Mousetrap.prototype.handleKey
self._handleKey
_getMatches
_handleKeyEvent
_characterFromEvent
_eventModifiers
Mousetrap.prototype.handleKey
self._handleKey
_getMatches

As you can see, _handleKeyEvent gets called 6 times. I'm guessing the buildup of those calls as I type is what slows the characters from showing in the input.

Looking into the issue on stackoverflow, I see a similar issue with a jQuery library: "The keydown event in combination with an html textbox will not be sufficient to prevent it from being fired multiple times." Is mousetrap being connected to the keydown and that's firing multiple times?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant