Just wondering if I can create a custom shortcut key to change the font color of the notebook text.

I've created a custom shortcut (in dkyeventtransactions.tr) to bring up the font color dialog, as so...

Item[KeyEvent["q", Modifiers -> {Control}],  

but I'm hoping to create different shortcut keys to change the font directly to different colors, without using the font color selection dialog.

  • $\begingroup$ Thanks Kuba, this is very close, but it seems to have the effect of coloring all the characters in the line before the spot that I use it, rather than just change the color for the characters I type next. I your example below, if I were to use the press [Ctrl]-t after typeing dsf, it will change the dsf to red also. $\endgroup$
    – mitcheljh
    Commented May 10, 2014 at 13:02

2 Answers 2


You have to add the following statement to the KeyEventTranslations.tr file:

Item[KeyEvent["t", Modifiers -> {Control}],
                 FrontEnd`NotebookSelection[ FrontEnd`InputNotebook[]], 
                 FontColor -> RGBColor[1, 0, 0]]]]

enter image description here

Be careful: there are not many "free" letters available and when you use one that is already in use, it will not work :)

p.s. a more flexible solution is available with Shortcuts package and joker functionality, just proceed like in: 72914

  • $\begingroup$ How does one use this using the joker functionality? I tried including NotebookApply[SelectedNotebook[], FrontEndExecute[ FrontEndSetOptions[ FrontEndNotebookSelection[ FrontEndInputNotebook[]], FontColor -> RGBColor[1, 0, 0]]], Before]` in the joker file, but this is wrong as it produces Null (as well as switching to a red font). What is my mistake? It also does not switch the font to red if the selection is not currently on a new line, but this is a minor issue. $\endgroup$
    – Kvothe
    Commented Oct 2, 2017 at 16:17
  • $\begingroup$ @Kvothe put SetOptions[ NotebookSelection[ InputNotebook[]], FontColor -> RGBColor[1, 0, 0]], that should be enough $\endgroup$
    – Kuba
    Commented Oct 3, 2017 at 11:23

One can change

MenuItem["Red",     FontColor->RGBColor[1, 0, 0]],

to, e. g.,

MenuItem["Red",     FontColor->RGBColor[1, 0, 0], MenuKey["r", Modifiers->{"Control"}]],

in the MenuSetup.tr file.


This has the additional advantage of adding the shortcuts to the menu for easier lookup.


  • $\begingroup$ Where is one supposed to make the suggested change? $\endgroup$
    – divenex
    Commented Jan 17, 2021 at 18:15
  • $\begingroup$ SystemOpen@FileNameJoin@{$InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources", "Windows"} (make sure to save a copy before editing), see also How do I add new menuitems to menus? $\endgroup$
    – Sterling
    Commented Mar 27, 2021 at 2:42
  • $\begingroup$ To avoid messing with the $InstallationDirectory, copy MenuSetup.tr to SystemOpen@FileNameJoin@{$UserBaseDirectory, "SystemFiles", "FrontEnd", "TextResources", "Windows"} and edit there. You may need to manually create some of those folders. Should take precedence over the other MenuSetup.tr file. $\endgroup$
    – Sterling
    Commented Mar 27, 2021 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.