I am preparing a language deck which contains two buttons for extra information. One of them contains an example sentence and the other the translation of the example sentence.
So, I was wondering if there was any way to assign some shortcut keys for these buttons.
Try adding the following code at the end of the <script> tag.
// Remove the event listener registered on the previous card
if (typeof myKeyboardEventHandler !== 'undefined') {
document.removeEventListener('keydown', myKeyboardEventHandler);
}
function myKeyboardEventHandler(event) {
if (event.key === 'F7') {
showExs();
} else if (event.key === 'F8') {
showTra();
}
}
document.addEventListener('keydown', myKeyboardEventHandler);
If you are using an older version of Anki 2.1, Refocus Card when Reviewing (2.1) add-on is required for shortcut keys to work. In addition, keys already assigned by Anki itself or add-ons cannot be used.
The problem is that you need to click on somewhere on the flashcard first. It is like when you have two different tabs in front of you and you cannot switch between them unless you click.