Keyboard Switcher
Automatically switch your operating system's keyboard input language
based on the Card Type of the card you're currently reviewing.
Studying with a note type like Japanese -> German? This addon detects
that a card of that type is on screen and switches your Mac or PC's
keyboard input language to German (or whatever you configure) for you --
no more manually flipping your keyboard language every time you switch
direction.
This changes the real, system-level keyboard input language (the same
thing you'd change by hand in your OS's language settings) -- not just
something internal to Anki -- so anything you type anywhere is
immediately in the right language.
Note: this addon matches on the card template name, and Anki's
built-in note types normally use generic template names like Card 1.
You'll need to create/rename your own templates with meaningful names
(e.g. Japanese -> German) -- see "How to use it" below for exact
steps. You can't match against the default Card 1 / Card 2 names
unless you rename them yourself first.
Setup (required -- please read before using)
This addon controls your operating system's input language directly, so
both Windows and macOS require a one-time permission or configuration
step before it will actually work. The addon will not silently fail
forever -- if something's misconfigured, check the log file mentioned
at the bottom of this page and it will tell you exactly what's wrong.
Windows
No special permission is required. Just make sure every language you
want to switch to is already added under:
Settings -> Time & Language -> Language & region
Only languages you've added there will show up in the addon's dropdown --
the addon reads this list directly from Windows, it doesn't install
languages for you.
macOS
Two things are required:
-
Add every input source you want to use under:
System Settings -> Keyboard -> Input Sources -> Edit...
(or System Settings -> Keyboard -> Text Input -> Input Sources on
some macOS versions). Only enabled sources appear in the addon's
dropdown.
-
Grant Anki two privacy permissions, both under
System Settings -> Privacy & Security:
- Accessibility -- add
Anki.app and enable it.
- Input Monitoring -- add
Anki.app and enable it.
Both matter: plain keyboard layouts (German, French, English, etc.)
generally only need Accessibility, but switching into input methods
for languages like Japanese, Chinese, or Korean specifically requires
Input Monitoring as well -- macOS treats these as a more sensitive
category of switch.
After granting either permission, fully quit Anki (Cmd+Q, not just
closing the window) and reopen it -- macOS only applies newly
granted permissions to a fresh process.
If Anki isn't listed yet under either permission at all, just open the
configuration dialog (see below) or review a card once; macOS will
usually prompt you automatically, or you can add Anki manually with
the + button in each permission list.
How to use it
-
In Anki, go to Tools -> Keyboard Switcher...
-
Click + Add Condition.
-
In Card Type Name, type the exact name of the card template
(not the note type!) as it appears in your note type's card layout
editor -- e.g. Japanese -> German. You can find this name in
Tools -> Manage Note Types -> [your note type] -> Cards...; it's
the tab name shown at the top of the card template editor.
Important: Anki's built-in note types come with generic template
names like Card 1 or Card 2. Since one template name is rarely
unique to a single language direction, you'll usually want to rename
the template to something meaningful yourself first -- e.g. rename
Card 1 to Japanese -> German. To rename a template, open
Tools -> Manage Note Types -> [your note type] -> Cards...,
double-click the tab name at the top (or use the rename button, if
your Anki version has one), type the new name, and save. Only after
renaming it will that exact name be available to match against in a
rule here.
-
In Input Language, pick the language to switch to from the
dropdown. This list is populated automatically from the languages
installed and enabled on your computer -- nothing to type by hand.
-
Click + Add Condition again to add as many rules as you like --
there's no limit.
-
(Optional) Tick Match Card Type Name case-insensitively if you'd
rather not worry about exact capitalization.
-
Click Save.
From now on, every time the reviewer shows a card whose card type
matches one of your rules, your keyboard input language switches
automatically -- no further action needed.
To edit or remove a rule later, reopen Tools -> Keyboard Switcher...,
adjust as needed, and click Save again. Click Remove on any row
to delete that rule.
Troubleshooting
If switching doesn't seem to work, open the addon's log file:
- Windows:
%APPDATA%\Anki2\addons21\keyboard_switcher\keyboard_switcher.log
- macOS:
~/Library/Application Support/Anki2/addons21/keyboard_switcher/keyboard_switcher.log
- Linux:
~/.local/share/Anki2/addons21/keyboard_switcher/keyboard_switcher.log
Review a card that should trigger a rule, then check the newest lines:
- No new lines appear at all -- the reviewer hook isn't firing, or
something's preventing Anki from loading the addon; check for an error
dialog on Anki startup.
- "did not match any of N configured rule(s)" -- your Card Type Name
doesn't exactly match the card's actual template name. Double-check
spelling, spacing, and that you used the template name, not the note
type name.
- "matched rule" followed by "reported success" but nothing visibly
changes -- the OS accepted the request; check that you selected the
correct language for that rule (typos are easy when several similarly
named input sources exist, e.g. multiple Japanese input methods).
- "matched rule" followed by a macOS OSStatus error -- almost always
a missing permission; re-check the Accessibility and Input Monitoring
steps above, making sure to fully quit and reopen Anki afterward.
Notes and limitations
- Languages must already be installed/enabled in your OS -- this addon
switches between existing languages, it doesn't install new ones.
- Switching applies to whatever window currently has focus at the moment
a card is shown, which in normal use is Anki itself.
- Linux support is best-effort (via IBus, falling back to XKB layouts)
since Linux has no single standard input-switching API across
distributions and desktop environments.