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

Shortcut failing. #72

Open
huandney opened this issue Jan 22, 2022 · 7 comments
Open

Shortcut failing. #72

huandney opened this issue Jan 22, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@huandney
Copy link

Hi,
The shortcut (Alt + the number keys) fails during review, and sometimes I need to close and open anki to get it working again.
This has happened in previous versions, but not as often.

Info:
Anki version 2.1.49
Windows 10

@3ter
Copy link
Collaborator

3ter commented Jan 23, 2022

Could it be that you press alt on its own? Another press (without any number in between) alleviates the alt-lock in my case. Apart from this it never failed as far as I can tell.

Can you run the console version of anki and check for errors when it happens?

@huandney
Copy link
Author

huandney commented Jan 23, 2022

Could it be that you press alt on its own? Another press (without any number in between) alleviates the alt-lock in my case. Apart from this it never failed as far as I can tell.

The error doesn't seem to be that. I noticed that whenever we redo a card by the shortcut CTRL+Z the error happens, and shortcut Alt + the number keys stops responding. If I go back to the decklist, then to the review (shortcuts: DSS), the shortcut works again.

Can you run the console version of anki and check for errors when it happens?

How can I do this?

@3ter
Copy link
Collaborator

3ter commented Jan 25, 2022

Yeah, I could reproduce it (it happens on Linux as well).

When returning with ^Z there seems to be another listener from the new card that lingers and overwrites the changes done with the shortcuts (here the third option is pressed but it is overwritten immediately afterwards):

JS info :143 0 0 1
JS info :143 0 0 0

You'll get the debug output when using the console version of anki.

I currently don't have much time on my hands unfortunately. But it shouldn't be too hard to figure out why this

anki-mc/card/back.html

Lines 110 to 111 in 3ae8088

// To make sure there isn't a previously registered event handler lingering into the next review
document.removeEventListener('keydown', tickCheckboxOnNumberKeyDown, false);

isn't working in the case of returning to a review with ^Z.

@3ter 3ter added the bug Something isn't working label Oct 30, 2022
@zjosua
Copy link
Owner

zjosua commented Nov 20, 2022

Was also able to reproduce this on Linux.
Using AnkiWebView Inspector, I confirmed that the event listener indeed was registered multiple times after ^Zing.
However adding document.removeEventListener('keydown', tickCheckboxOnNumberKeyDown, false); on the front template before adding the event listener didn't fix the issue.

@3ter
Copy link
Collaborator

3ter commented Nov 20, 2022

@zjosua I suppose we could add another listener that removes the old listener as soon as the page unloads (https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event). Or we transform this into JavaScript: https://gist.github.com/screamingworld/4d8ee991be564564e9725d919dd83841#file-jsts-event-listener-solution-ts

@Shahin-rmz
Copy link

I have a workaround for this issue, when I reload anki question (with the help of another anki addon) it works again after ctrl z.
here is the Addon. and ctrl + R for reloading.

@Shahin-rmz
Copy link

Is there any shortcuts for true false questions?
I can work with my keyboard on the complete deck except true false questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants