# How do I make a keyboard shortcut to change the color of selected text?

I am a beginner.

I would like to add a keyboard shortcut to the Format > Text Color > Red menu item.

I know I can type alt-r-x-up arrow-up arrow-return (Windows7). But I want to include this command with others for the (excellent) external shortcut maker that I use (Clavier+). If I don't, Clavier+ is too slow and it ends up in a mess.

I tried to search in the already answered questions, but could not go very far. My ultimate goald would be to have a shortcut for

textcolor=red

"-" (type "negative")

clear formatting

So there are 2 questions :

1. how and where can I add something like MenuKey["r", Modifiers->{"Control+Alt"}] to type directly in red

2. is it possible to make macros in Mathematica to concatenate several commands ?

I hope I was clear.

• Do those answer work for you: 47474? – Kuba Oct 30 '17 at 9:14

The easiest way to do this is to first copy your MenuSetup.tr file:

Quiet@
CopyFile[#,
newSetup =
If[FileExistsQ@
StringTrim[#, $InstallationDirectory |$UserBaseDirectory | \
$BaseDirectory], StringTrim[#,$InstallationDirectory | $UserBaseDirectory | \$BaseDirectory],
FileNameJoin@{$UserBaseDirectory, StringTrim[#,$InstallationDirectory | $UserBaseDirectory | \$BaseDirectory]
}]
] &@FrontEndExecute@
FrontEndFindFileOnPath["MenuSetup.tr",
"PrivatePathsTextResources"];
SystemOpen@newSetup


Search in that newSetup for "Text Color"

Replace the MenuItem for "Red" with this:

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


Then reset the menu with this:

FrontEndExecute@{
FrontEndFlushTextResourceCaches[],
FrontEndResetMenusPacket[{Automatic, Automatic}]
}


Alternately, I have a chunk of code that I detailed here with a better implementation here that lets you do things like this:

FEMenuSetupAdd[
{"Mathematica", "Format", "Text Color"},
"Tangerine" :> FontColor -> RGBColor[1, .5, 0],

But I can't fully remember how to remove the MenuKey afterwards, so only use that if you are really feeling it.
• @dennis You 100% can overwrite the shortcuts. "Te&xt Color"` is undoubtedly just what Windows calls it. What happens, then, when you select a chunk of text and press Control+Shift+-? – b3m2a1 Oct 30 '17 at 8:52