Make hints clickable using hotkeys

I have been using extra fields for hint, but lately I have come across some cards that require me to add multiple hints. For example, I have one long paragraph that I need to memorize word for word and that contains several points and examples respectively, and since I have to memorize the paragraph as a whole and I don’t want to leave out examples that help me memorize even though they don’t require memorizing, I have to use html in each note, instead of template. I wonder if it’s feasible to make hints clickable using hotkey.

You can assign hotkeys to trigger hints using some JavaScript:

{{hint:Field1}}
<br>
{{hint:Field2}}


<script>
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values
var hotkeys = ["KeyH", "KeyJ"];
var hints = document.querySelectorAll("a.hint");
document.addEventListener("keydown", e => {
    var hintIndex = hotkeys.indexOf(e.code);
    if(hintIndex !== -1) {
        hints[hintIndex].click();
    }
});
</script>
2 Likes