# Can I use Anki's shortcuts in the Anki template?

**URL:** <https://forums.ankiweb.net/t/can-i-use-ankis-shortcuts-in-the-anki-template/60707>\
**Category:** Card Design\
**Created:** [May 10, 2025, 11:38pm UTC](https://forums.ankiweb.net/t/can-i-use-ankis-shortcuts-in-the-anki-template/60707 "2025-05-10T23:38:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anki10](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anki10](https://forums.ankiweb.net/u/anki10)\
**Post date:** [May 10, 2025, 11:38pm UTC](https://forums.ankiweb.net/t/can-i-use-ankis-shortcuts-in-the-anki-template/60707/1 "2025-05-10T23:38:38Z")

</div>

Can the shortcut keys of Anki be called within the Anki template? For example, in the back of Anki, when pressing ‘difficult’, can it call the shortcut key to automatically add the red flag, like how adding a red flag in Anki is ctrl 1?

---

<div class="post-metadata">

**Author:** ![Anon\_0000](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Anon\_0000](https://forums.ankiweb.net/u/Anon_0000)\
**Post date:** [May 10, 2025, 11:45pm UTC](https://forums.ankiweb.net/t/can-i-use-ankis-shortcuts-in-the-anki-template/60707/2 "2025-05-10T23:45:33Z")

</div>

I looked up something similar a short while ago because a user wanted to trigger the undo command from within the card templates.

The result of me trying and of my research suggest that shortcuts from the browser cannot be called from within a webpage (or anki template in this case). This apparently is a security feature.

Though maybe there is an API available that would still allow you to do that. Otherwise, it’s impossible to call a browser shortcut like Ctrl+1 from within the card template as far as I know.

---

<div class="post-metadata">

**Author:** ![anki10](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anki10](https://forums.ankiweb.net/u/anki10)\
**Post date:** [May 10, 2025, 11:50pm UTC](https://forums.ankiweb.net/t/can-i-use-ankis-shortcuts-in-the-anki-template/60707/3 "2025-05-10T23:50:54Z")

</div>

I just want to add flag markers to the cards for convenience, without having to mark them manually. I’m not sure if there are any safety considerations. Thank you for your reply.

---

<div class="post-metadata">

**Author:** ![Anon\_0000](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Anon\_0000](https://forums.ankiweb.net/u/Anon_0000)\
**Post date:** [May 11, 2025, 12:13am UTC](https://forums.ankiweb.net/t/can-i-use-ankis-shortcuts-in-the-anki-template/60707/4 "2025-05-11T00:13:14Z")

</div>

I was trying to say that it’s not possible.

Even if you’d set the flag programatically with js, so that you get the following correct html, anki would’t show the card as “flag 1”:

```html
<div id="_flag" style="color: var(--flag-1);">⚑</div>

```

The reason is security restrictions that are build in web browsers. Anki on desktop uses a browser, too, which is based on the chromium browser.

In other words: There’s no way to achieve what you’re looking for using card templates (except if anki devs provided APIs for that, which I cannot answer as I do not know).

---

<div class="post-metadata">

**Author:** ![Eltaurus](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/eltaurus/32/10287_2.png) [@Eltaurus](https://forums.ankiweb.net/u/Eltaurus)\
**Post date:** [May 11, 2025, 1:27am UTC](https://forums.ankiweb.net/t/can-i-use-ankis-shortcuts-in-the-anki-template/60707/5 "2025-05-11T01:27:19Z")

</div>

On desktop, you can do that if you use an add-on that catches the needed JS commands, like [this one](https://ankiweb.net/shared/info/1230570706). On Android, this should be available using AnkiDroid’s [API](https://github.com/lonewolf2208/Wiki-Ankidroid/blob/master/AnkiDroid-Javascript-API.md#flag--remove-flag-in-current-card)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [June 10, 2025, 1:27am UTC](https://forums.ankiweb.net/t/can-i-use-ankis-shortcuts-in-the-anki-template/60707/6 "2025-06-10T01:27:23Z")

</div>

Closed on June 10, 2025, 1:27am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
