Cache mousemove and hook keyboard to allow scanning at mouse position while mouse is no longer moving #917
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #533
Something worth noting here is how the following interations work:
Interaction 1:
This works totally fine. Both times the user presses the button to scan they will get the popup and the word will be scanned.
Interaction 2:
This does not work. The user will get the first popup but then the second popup won't show (unless the user was scanning a word inside the first popup). This is because the user's browser will have focused inside the popup window and all event listeners outside of it can no longer access the keypresses.
On a normal webpage this wouldn't be an issue but Yomitan popups actually aren't even the same webpage. And a browser will not allow a webpage to access keystrokes being sent inside a different webpage. This behavior applies regardless of whether Yomitan is using a secure container and url or not.
Now this may raise the question of why moving the mouse before scanning while a different popup is open allows scanning with no problems. This is because modifier data can be accessed through mouse events and the browser will let those through since the mouse is hovering over the parent webpage with the event listener in it and not the popup's separate webpage.