91 14
Contact Author Sign in to rate

Quick Colour Changing

<10kB. Updated 2022-07-24.
The author has shared 13 other item(s).

Description

This addon allows you to define shortcut keys to set the selected text to a specific colour in the editor. Updated recently to change the default shortcuts, as F11 is now used by Anki. In Anki 2.1, you can customize the shortcuts and colours by clicking on Config in the add-ons dialog. In Anki 2.0, you'll need to edit the add-on source code.

Download

As add-ons are programs downloaded from the internet, they are potentially malicious. You should only download add-ons you trust.

Supported Anki versions:

To download this add-on, please copy and paste the following code into Anki 2.1:

2491935955

If you were linked to this page from the internet, please open Anki on your computer, go to the Tools->Add-ons menu item, then click on Get Add-ons and paste in the code.

All Anki 2.1.x Add-Ons Contact Author

Reviews

on 1680002976
Very convenient!
on 1679069484
Works great
on 1673895881
{
"keys": [
[
"black",
"Alt+x"
],
[
"red",
"Alt+r"
],
[
"green",
"Alt+g"
],
[
"blue",
"Alt+b"
]
]
}
on 1672913523
Scroll down for a set up you can copy and edit your preferred setup.

I am using this, the colors are mine, but the code I got from another comment.

{
"keys": [
[
"#9aff4c",
"F1"
],
[
"#ffc85a",
"F2"
],
[
"#ffff7f",
"F11"
],
[
"#eeb9ff",
"F12"
],
[
"#848484",
"F4"
],
[
"#b5ffda",
"F3"
]
]
}
Restart to make it work.
on 1672591406
Thank you, saved lots of my time!
on 1666438770
There is one issue with this, I cannot change color of text that was Copy and paste to the anki
:(( how to solve this ?
on 1664815228
Amazing. Should be integrated into the core Anki build, imo.
on 1662306451
This add-on is a life saver, but I am encountering an issue where any text color set by the add-on will ignore the text-decoration-color I have set in my cloze card type. This issue does not occur if I use the built in Anki text editor to select the color, only when I use the shortcut from this add-on.

I typically have many clozes per note, and all of them are colored differently based on the type of fact I am trying to learn. However, given all the colored text, I find it helpful to keep the cloze underlined in a different color after flipping the card. I would like this underline color to maintain the color of the initial cloze, not the color of the text itself after it has been flipped.
on 1658765078
Perfect addon. The F11 key works completely fine for me on Anki 2.1.54 -- if you're having trouble with that maybe you need to change some settings.
on 1658486215
Why can't I use the F11 key?
I have just Anki 2.1.54 with this addon (no other addons) with the default configuration, and steel pressing F11 has no effect (F12 works OK).
I can customize and use Ctrl+F11, which works well, but F11 alone is a different story: it can't use it, and I don't know why.
on 1656226990
doesn't work
on 1652192710
Essential for me, use it constantly, saves so much time. Works fine on 2.1.51.
on 1650300670
Works well. Wish it worked with edit fields while reviewing
on 1649945942
It's working on 2.49, but isn't on 2.5
Hope you'll update, your add-on helps me a lot.
on 1648157209
Doesn't work on Anki 2.1.49

Anki 2.1.49 (dc80804a) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-03-24 21:53:27

Caught exception:
Traceback (most recent call last):
File "aqt\webview.py", line 41, in cmd
File "aqt\webview.py", line 142, in _onCmd
File "aqt\webview.py", line 595, in _onBridgeCmd
File "aqt\toolbar.py", line 168, in _linkHandler
File "aqt\toolbar.py", line 186, in _browseLinkHandler
File "aqt\main.py", line 1119, in onBrowse
File "aqt\__init__.py", line 116, in open
File "aqt\browser\browser.py", line 132, in __init__
File "aqt\browser\browser.py", line 416, in setupEditor
File "aqt\editor.py", line 116, in __init__
File "aqt\editor.py", line 308, in setupShortcuts
File "aqt\hooks_gen.py", line 1921, in __call__
File "anki\hooks.py", line 34, in runHook
File "C:\Users\OWNER\AppData\Roaming\Anki2\addons21\2491935955\__init__.py", line 19, in onSetupShortcuts
for code, key in config['keys']:
ValueError: not enough values to unpack (expected 2, got 0)

This is my init.py:

# -*- coding: utf-8 -*-
# Copyright: Damien Elmes <anki@ichi2.net>
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
#

from aqt import mw

config = mw.addonManager.getConfig(__name__)

from anki.hooks import addHook

def updateColour(editor, colour):
editor.fcolour = colour
editor.onColourChanged()
editor._wrapWithColour(editor.fcolour)

def onSetupShortcuts(cuts, editor):
# add colours
for code, key in config['keys']:
cuts.append((key, lambda c=code: updateColour(editor, c)))

addHook("setupEditorShortcuts", onSetupShortcuts)

This error message also pops up when I attempt to change the colors:

Anki 2.1.49 (dc80804a) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-03-24 21:53:27

Caught exception:
Traceback (most recent call last):
File "aqt\taskman.py", line 101, in _on_closures_pending
File "aqt\taskman.py", line 71, in <lambda>
File "aqt\taskman.py", line 90, in wrapped_done
File "aqt\operations\__init__.py", line 117, in wrapped_done
File "aqt\operations\__init__.py", line 136, in _fire_change_hooks_after_op_performed
File "aqt\hooks_gen.py", line 2859, in __call__
File "aqt\browser\browser.py", line 148, in on_operation_did_execute
AttributeError: 'Browser' object has no attribute 'editor'

This is my Meta.json:
{"name": "Quick Colour Changing", "mod": 1503924482, "min_point_version": 0, "max_point_version": 15, "branch_index": 0, "config": {"keys": [["#a4a4ff", "Alt+1"], ["red", "Alt+2"], ["green", "Alt+3"], ["orange", "Alt+4"]]}, "disabled": false, "conflicts": [], "update_enabled": true}

Behaviour:
When I press Alt+1 or Alt+2, nothing happens.

When I press Alt+3 or Alt+4, it works as expected.

Changing Alt+1 or Alt+2 to something else doesn't work.

Changing the color of Alt+3 from Green to Red for example, doesn't change. It stays Green.
on 1644076176
It is very easy to use and saves time.
on 1642566914
Great
on 1642395581
Good time saver

Edit: As a head's up, it doesn't seem to work with Anki 2.1.50 beta
on 1639391574
good
on 1633687899
USING IN RAPID REVIEW AND BROWSER

This app is very useful, but the color changing shortcuts are not working in the quick-edit card section in the card browser. If this would work in that section, I would gladly rate it 5 stars. The shortcuts will work in review and browser
on 1633108529
Good add on
on 1632247733
Very convenient thanks
on 1628002475
Great, thanks a lot!
on 1627708265
If you are using this plugin on a Mac, be sure to pay attention to the configuration file, Ctrl will map to Command, Meta will map to Ctrl. The following is from PyQt's documentation

On macOS, references to “Ctrl”, CTRL , Key_Control and ControlModifier correspond to the Command keys on the Macintosh keyboard, and references to “Meta”, META , Key_Meta and MetaModifier correspond to the Control keys. Developers on macOS can use the same shortcut descriptions across all platforms, and their applications will automatically work as expected on macOS.

https://doc.qt.io/qtforpython-5/PySide2/QtGui/QKeySequence.html#more
on 1625743191
Godsend!! 😋

I use it daily, each time I write a new card, as I like to make additional information surrounded by parentheses to be of gray colour.
on 1622155413
Thanks very much for the Add-on! I use it a lot and it saves a huge amount of time.
on 1618903386
this works like charm, as I'm already used to this in other program ,which is assign short cut key to high light text with certain color. I'm disappointed to see most downvotes comes from the people who didn't bother to spend time examining how to use it in the first place.
on 1617361303
Should be implemented in Anki
Must have add-on
on 1614211866
Great work! The user must be careful to use shotcuts that won't affect the normal functions of anki (or other addons).

My keys:
{
"keys": [
[
"black",
"Alt+1"
],
[
"red",
"Alt+2"
],
[
"green",
"Alt+3"
],
[
"blue",
"Alt+4"
]
]
}
on 1609304890
This allows me to modify font color along with colors of Anki iOS edition much more easily!
I referred to another fan's configuration, and slightly modified key assign to work in Anki 2.1.22 as below.

(*) Shift+Ctrl+r, Shift+Ctrl+e didn't work in my environment.

{
"keys": [
[ "#0a84ff", "Shift+Ctrl+b" ],
[ "#30d158", "Shift+Ctrl+g" ],
[ "#ff9f0a", "F11" ],
[ "#ff453a", "F12" ]
]
}

------
It worked on Windows 10 and Linux (Fedora).
It needs restart of Anki to make changes take effect.
on 1604804707
effective
on 1602930875
Really a pitty that F3 doesn't work.

Besides that an absolutely great tool. If it doesn't work at all for for you, try restarting Anki.
on 1597405598
simple, works great on Mac OS on both Browser and in Add mode, you just have to restart after editing the shortcuts. I use:
{ "keys": [ [ "green","Alt+x" ], [ "blue", "Alt+z" ], [ "orange", "Alt+a" ], [ "black", "Alt+s" ] ] }
on 1594972823
nice!
on 1593719496
Super! It really helped me to save time (4000+ cards lol). I used it for colour-coding my german deck (by gender), so I remember the words with an specific colour depending on its gender.
on 1590934613
Great add-on. Also looking for an add-on where the multiple colors show up on top of the adding/editing screen of a card. Nonetheless this works
on 1590895097
Such a time saver! Thanks for the work on this one :)
on 1590691446
Once you enter the html in 'settings' in 'add ons' (assign colours the keyboard shortcut), you have to close and reopen anki for the changes to take effect.
on 1590500085
If it doesn't work, you could try restarting.
on 1586430916
For anyone interested, I synced the colors with the iOS app for working with the Black background on the phone. These are the same colors the app uses (Using regular Blue was an issue, I just adapted all of them).
The order is: Blue, Green, orangE, Red
„Shift+Cmd+b/g/e/r“ (Cmd is written as Ctrl, see below).

Thanks to those who developed this and those who commented below!

{
"keys": [
[
"#0a84ff",
"Shift+Ctrl+b"
],
[
"#30d158",
"Shift+Ctrl+g"
],
[
"#ff9f0a",
"Shift+Ctrl+e"
],
[
"#ff453a",
"Shift+Ctrl+r"
]
]
}
on 1586389835
Would be awesome to also make it work with "edit while reviewing" add-on is that possible ?
on 1585222446
nice
on 1585069503
Excellent in editor mode; however, it would be awesome if you could make this compatible with the edit field during cloze review/image resizer add-on. Thanks for your work!
on 1581449352
Does not work in the browser
on 1578897104
I love this a lot! Making text transparent is now so much easier

P.S. although I love the addon, I think overwriting the F8 button is a bad idea.
Even if you set the shortcut to something else the F8 button will not return doing its usual job because of the addon.
Fixing it is very easy though
Here's how: https://imgur.com/a/jJYKnoi
on 1578146424
Very helpful in quick entering while doing courses, reading new vocabulary that need to highlight colors
on 1576630945
works well for me...

but saw in the review section some having troubles with adding more than 2 colors, hope the following steps will help( windows 10 anki 2.1 version)


1)after adding the add on , go to the tools -> add-ons -> select the quick color changing -> click config -> then on the configuration window:

it should look like this:
{
"keys": [
[
"red",
"F11"
],
[
"#00f",
"F12"
]
]
}

2) to add more colors or to change the controls:
a) keep the beginning and ending tags intact
beginning tags { "keys": [
ending tags ] }

b) then can edit in between - it was easier for me to use ctrl+ alt keys together as controls
["red", "F11" ], u can change it to ["red","Ctrl+Alt+r" ],
[ "#00f", "F12"] u can change it to ["blue","Ctrl+Alt+b"],

c) to add a color of your choice:
go to anki add page -> change color button or F8 -> in the 'select color' window look for the HTML code for the color and copy it. then you can use it to customize
ex:for purple
["#aa00ff","Ctrl+Alt+p"],

d) you can keep on adding colors and controls of your choice.
*in between 2 color commands there should be a comma and in the last color command no comma is required
ex:
{
"keys": [
["red","Ctrl+Alt+r"],
["blue","Ctrl+Alt+b"],
["#ff00ff ","Ctrl+Alt+x"]
]
}

or you can copy paste the following and edit it as you want -> if it doesn't work go for restore defaults


{
"keys": [
["red","Ctrl+Alt+r"],
["blue","Ctrl+Alt+b"],
["#00ff00","Ctrl+Alt+g"],
["yellow","Ctrl+Alt+y"],
["#aa00ff","Ctrl+Alt+p"],
["#ffaa00","Ctrl+Alt+o"],
["#55aaff","Ctrl+Alt+n"],
["#ff557f","Ctrl+Alt+z"],
["#ff00ff ","Ctrl+Alt+x"]
]
}

e) restart the anki app
on 1575793044
Great. Thanks!

For those who'd like to have (say) four colours, the easiest way to do so is by opening the Addon list, select View Files, duplicate the folder in question, and restart Anki.
on 1575478567
works good. Thank you!
on 1573695766
Thanks!
on 1573018096
ok
on 1567644354
用不了
on 1567414004
Very nice app, but I can not figure out how to add more than 2 colours.
I can change the 2 colours the default setting came with and the hotkeys, but if I try to add more code I just end up with error.
on 1567132922
It can mark some important informations with different colours
on 1565622412
Works for me!
on 1562147012
你好,如果在此基础上,增加设置文字加粗设置就好了。如按一个组合快捷键alt+z,就可设置颜色红色并加粗。如果能实现,那太棒了。
为什么有此需求呢?为了更加突出。
on 1560696550
l can't even open it .Is it my computer's problem?My anki's vension is 2.1.
on 1560421837
添加插件后,需选择“工具”,“附加组件”,选中“Quick Colour Changing”,点击“设置”,可以更改快捷键和颜色,会有提示,希望帮助到你.
After adding the plugin, you need to select "Tools", "Add-ons", select "Quick Colour Changing", click "Config", you can change the shortcut keys and colors, there will be tips, I hope it can help you.
on 1560036472
这玩意怎么用啊,半天 添加不了 新颜色。
on 1559173256
I really have no idea how to use it. No option to apply it anywhere at all! Please write instructions, it'd be of great help.
on 1558428958
I have no idea how to make this program work. There is no explanation, no screenshots, nothing. I assume these are supposed to work in the edit/create screen for new cards but after 30min, I'm giving up on trying to make it work. If this is the "quick" way to change colors, I don't want to know what the slow way is.
on 1557261011
Anki 2.1 version works as expected. I like the new configuration window too. For macOS users, remember that "ctrl" means your command button (⌘), not control (⌃). If you want to use your mac's control button, refer to it as "meta". E.g., ["red", "meta+r"] translates to ⌃ + r on a mac.
on 1554050563
Works great!!!
on 1552689835
Works perfectly!

I had some keyboard hotkey conflicts with Alt, so I opted for Ctrl+Alt instead.

In case anyone has the same issue, here's what works for me:
For blue:
["blue","Ctrl+Alt+b"]
For red:
["red","Ctrl+Alt+r"]
For green:
["green","Ctrl+Alt+g"]
on 1552288338
2491935955
on 1551291076
For those who want info on adding buttons, scroll down to find the review from 9/6. That helped a lot.
Note: I was unable to add buttons to F7 but was able to add to F10. If you find yourself unable to add to one button, try again with another before proceeding to find another fix.
on 1544300045
At the moment this add-on caused a bug where I can't sync Anki. (I don't know if its the add-on itself or the combination between add ons)
Comment from author
Nothing this add-on changes should affect syncing.
on 1543649876
Thanks! It's very convenient, but I cannot use F7 and F8.
on 1540785546
!!!!!!!!!!!!!!!!
on 1540625431
Why this service is not applicable not Anki mobile?😭
on 1540429812
I downloaded python to open __init__.py and this is the code I see.


from aqt import mw

config = mw.addonManager.getConfig(__name__)

from anki.hooks import addHook

def updateColour(editor, colour):
editor.fcolour = colour
editor.onColourChanged()
editor._wrapWithColour(editor.fcolour)

def onSetupShortcuts(cuts, editor):
# add colours
for code, key in config['keys']:
cuts.append((key, lambda c=code: updateColour(editor, c)))

addHook("setupEditorShortcuts", onSetupShortcuts)



Where exactly am I supposed to paste the following ?

("red", "alt+r"),
("blue", "alt+b"),
("chocolate", "alt+c"),
("black", "alt+x"),
("white", "alt+w"),

Please, thank you
on 1539550710
Nice!
on 1537556734
easy to use and edit
on 1537430627
Essential.
on 1536341992
Extremely helpful!
on 1536222335
Je n'arrive pas à changer les réglages, aucun ne fonctionne
on 1534405688
Excellent!
on 1530428559
red
on 1520553600
Excelente !!! Acelerou bastante a criação de novos flashcards!! Adicionei os códigos com as outras cores que os colegas indicaram e ficou melhor ainda
on 1515110400
Saves time making cards and allows entry of whatever HTML colour codes you want
on 1508198400
on 1504742400
Works well - tweaks for Macbook user learning Mandarin

This add on is just what I was looking for, and the comments left below were very helpful. To save someone spending the 40 minutes I did on exploring the shortcuts for a Macbook, some tips:

- The 'alt' shortcuts didn't seem to work for me because they interfered with other shortcuts already in the system

- For using the 'F' keys (i.e. fn + the relevant key) I had to disable some functionality associated with those keys before they would work changing colours (e.g. showing all windows at once). This can be done by going to System Preferences>Keyboard>Shortcuts and deselecting the options for F8 - F10 under 'Mission Control', 'Keyboard'. I never really used those F keys so it isn't a problem for me.

- I'm starting to learn Mandarin so I used a slightly different order for the colours which match the order of the tones and how I think of their sounds; and which might be helpful to others (relevant bid of code below).

Blue - F8/1st tone (high tone in sky)
Green - F9/2nd tone (rising from the trees)
Brown - F10/3rd tone (low in the ground/mud)
Red - F11/4th tone (slightly angry sound)
Black - F12

Code extract - put between the [ ]:

("red", "F11"),
("#00f", "F8"), ("#AA5603", "F10"), ("#000", "F12"), ("green", "F9")

Hope this is useful for others. Obviously you can swap around the colours etc.
on 1501891200
on 1501113600
works well, saves time!!

Use the belowing code to replace the former one( don't delete [] ). It works in the browser and the new card creating window.
("red", "alt+r"),
("blue", "alt+b"),
("chocolate", "alt+c"),
("black", "alt+x"),
("white", "alt+w"),
on 1500768000
on 1495670400
on 1492732800
on 1491782400
Works well, but 1 major complaint

This app is very useful, but the color changing shortcuts are not working in the quick-edit card section in the card browser. If this would work in that section, I would gladly rate it 5 stars.

Also, the code that the other reviewer posted is very helpful. Thank you for that.
on 1489190400
on 1475193600
Clue of add shortcuts

colours = [
("red", "F8"),
("#00f", "F9"), ("#AA5603", "F10"),("#000", "F11"), ("green", "F6")
]
on 1474675200
Great!

Works well. I could also create multikey shortcuts by moving the colours list below the import statements in the code. Below you can see that the yellow color can be applied by hitting Ctrl + P:


from aqt import mw
from aqt.qt import *
from anki.hooks import addHook

colours = [
("yellow", Qt.CTRL + Qt.Key_P),
]
on 1469404800
perhaps need updating

It works well on ver2.0.33, but failed on ver2.0.36
on 1464048000
on 1458000000
Old, but still gold!

Though this tool hasn't been updated for almost 4 years, it still works like a charm.

It works on Windows 10, Linux, Mac OS X. I use all these operating systems, and this adds-on works on all of them.

Someone posted 'not working' on mac, which is not true for my Mac OS X El Capitan. For those having trouble making it to work on Mac, please try to press 'fn' key at the same time when you press F8/F9/F10 key.

I also did a little modification to display 3 different colors - more than enough for my use.
on 1456963200
not working

using it on mac.
it's not working.
not F8/F9 nor if i try to use own shortcuts...
i edit and restart but it's not working...

maybe there is need some proper manual? but i don't think i made something wrong
on 1455667200
Yes, yes, yes!

Fantastic! This saves an immense amount of time for visually encoding gender (or really any other category...) into a deck for learners like me.
on 1444521600
on 1421884800
on 1415318400
on 1409616000
Saves times!!

on 1407024000
on 1399766400
Thanks to the guy who posted the mod for combo keys!

This addon is not bad, but as it was, it was not very useful. Who posted that little hack, thank you very much, because now it makes sense using this addon.
on 1383696000
Some issues

was hoping it could override the default hotkeys (like F3), but otherwise works great.

also wish Ctrl+R worked in the same way (subsequent text would be normal).
on 1375574400
on 1370649600