How can I make it so that pressing the spacebar marks the card as "easy"?

I’m creating an add-on that would allow the card to be marked as “easy” when you click enter or the spacebar 2x. However, I would like that if the card is new or still being learned, when I click enter or the 2x spacebar, the card is marked as “good” instead of “easy”. Could you help me? That’s what I’ve got so far:

from aqt.reviewer import Reviewer

def my_defaultEase(self):
    if self.card and self.card.type == 0:  # Check that the card is new
        return 3  # Set the default facility to 3 for new cards
    return 4  # Keeps the default facility as 4 for other cases

Reviewer._defaultEase = my_defaultEase

note: i know absolutely nothing about programming and all i’ve found out is by searching this forum and chatgpt

Maybe using Qtimer to measure the time and see if it is pressed twice within a second(0.5~1).

ChatGPT is quite useful, but does not generate much proper code. So if you want to create Anki add-ons with ChatGPT, you need to have a basic knowledge of Python(If not, you can’t correct ChatGPT lies or combine codes properly).

How to create Anki add-ons can be found in the AnkiManual.

I’d like anki’s response to be independent of the speed at which the key is pressed. I would like the only criterion for marking the card as “good” to be if the card is new or still being learned. If it’s neither, I’d like anki to mark it as “easy”. Unfortunately, I don’t have much time to learn how to program and I haven’t found an add-on that does this. If it’s not too difficult, could you edit the code for me? Thank you so much!

What do you mean when you say “spacebar 2x”?

  • Show answer (spacebar 1x), answer (spacebar 2x)

Or,

  • Press the spacebar once to answer “Good” (spacebar 1x), press the spacebar twice quickly to answer “Easy” (spacebar 2x)

the first option

I made the mistake of thinking it was the latter… :confused:

I think your code is fine. It seems to work fine on my device, so there is no need to modify it.

  • Review : Easy
  • New : Good
  • Learning : Good

The code has a flaw: use a new card as a test and press enter, the card will be marked as “good”. So far so good. However, the moment that card appears again, even though the card is still being learned, if you press enter the card will be marked as “easy” instead of “good”

Try using this code.

from aqt.reviewer import Reviewer
from anki.consts import CARD_TYPE_REV

def my_defaultEase(self):
    print(self.card.type)
    if self.card.type == CARD_TYPE_REV:
        return 4
    else:
        return 3

Reviewer._defaultEase = my_defaultEase
1 Like

Thanks a lot bro! You helped me a lot, the code worked perfectly!

1 Like