# Anki Spacebar Binder # Changes which answer button the spacebar presses on the answer side of a # card. Anki's default is Good. Set "spacebar" in the add-on's config to # "again", "hard", "good", or "easy" (or the number 1 to 4). # # Made by Ryleigh Newman for reviewing with a game controller, where one big # button sends Space: https://inputconfig.com/tools/anki-spacebar-binder from aqt import mw from aqt.reviewer import Reviewer BUTTONS = {"again": 1, "hard": 2, "good": 3, "easy": 4} def chosen_ease(): config = mw.addonManager.getConfig(__name__) or {} value = config.get("spacebar", "good") if isinstance(value, int) and 1 <= value <= 4: return value return BUTTONS.get(str(value).strip().lower(), 3) def spacebar_ease(self): ease = chosen_ease() # Cards with fewer buttons (a new card can show three) fall back to Good. if ease > self.mw.col.sched.answerButtons(self.card): return 3 return ease Reviewer._defaultEase = spacebar_ease