JS-script for Anki, that allows the creation of an interactive field for catching keys pressed on the keyboard against a pre-set shortcut. Built using JQuery.
Inspired by a site ShortcutFoo, this script allows you to build muscle memory for shortcuts by pressing them on the keyboard while reviewing a note in Anki.
Works on Windows, Linux and MacOS with standard QWERTY english layout.
shortcut_demonstration.mp4
- JS-powered interactive field for shortcut-drilling using Anki for Windows and Linux
- Table of Contents
-
Download on if the two premade decks with VScode Windows shortcuts from example_deck folder and import it to your Anki.
vscode-win-online.apkg
- import this deck if you'll be reviewing notes on a PC that has a constant internet connection. JS-script in this deck is linked to the latest version of the script in this GitHub repo. This will guarantee that you'll be using the latest version of the script.
vscode-win-offline.apkg
- download this deck if you don't want the script to depend on an internet connection. It will have the latest version of the script at the time of download. -
After import it will create a new note type
Shortcuts
with two fields:Action
for text-description of shortcut andShortCut
where you need to write shortcut itself.
Just use this note type to create your decks with the shortcuts you need.
- Create a new note type in the Anki browser with two fields -
Action
andShortCut
. - Copy templates for front and back from this HTML file. There are two templates for the front side - choose one depending on if
you want it to work offline or not (read above in the
Easy way
for more info on what's different about templates.) - Copy CSS stylings from this CSS file.
All keys should be either written with '+" or ' '(space) between them.
Examples:
Shift+Control+P
Control+K F12
Shift+Control+Alt+ArrowUp
cmd+Alt++
(this is a shortcut with three buttonscmd
,Alt
and+
)Control+K Control+0
All keys are independent of the register, so Alt
can be written as ALT
, Alt
or alt
.
Alt
should beAlt
.Shift
should beShift
.Enter
should beEnter
.Space
should beSpace
.Control
should always beControl
, never usectrl
.Backspace
,PageUp
,Delete
, and so on should be named as their full names without spaces.Meta
key (this isWin
key on windows,cmd
key on mac) should be written ascmd
orMeta
.- Arrow keys should be written like this
ArrowUp
,ArrowDown
,ArrowLeft
, andArrowRight
.
Other keys should be set as they are typed.
You can look up examples in pre-made decks for VScode in example_deck folder
-
Cards don't auto-flip if you correctly or incorrectly press shortcut, you just see the shortcut in green or red.
You'll still need to flip the card by pressing enter (or space) and then choosing answer option. -
I couldn't find a way in JS to reliably prevent hotkeys from triggering actions in OS or other soft, so some combinations of keys don't work:
- Shortcuts in Windows with the
Win
button. - Shortcuts that are in the user's other installed soft unless the user disables it in the soft itself (like Nvidia Overlay and other software that catches shortcuts anywhere in the system).
- Shortcuts that conflict with Anki shortcuts. The workaround is simple: install an addon Customize Keyboard Shortcuts and disable conflicting shortcuts. In the example_deck folder I added config for the addon with every conflicting shortcut for my VScode deck disabled.
- Shortcuts in Windows with the