I'm looking for a general "recipe" to do with a keyboard shortcut what I currently do with a PasteButton. Here is a working toy example PasteButton:

PasteButton[Subscript[Ω, \[SelectionPlaceholder]]]

It generates a capital Greek letter Omega (type in as \[CapitalOmega]) with a selection placeholder (black square) in the subscript.

To "keyboard-shortify" it, I know that I have to modify the file KeyEventTranslations.tr in


but what I have to put into this file is a lot more complicated than just copying from how the PasteButton does it.

If I wanted just the Ω without the subscript, associated with the keyboard stroke Control-Shift-Command-O, I would have to put the following:

    KeyEvent["O", Modifiers -> {Control, Command, Shift}],

but what I tried putting into the .tr file with Subscript did not work - it always put Subscript[something] literally into the current notebookOmega screen shot

I tried to write some code with SelectionMove[] and SelectionEvaluate[] and putting that into the .tr file, but it didn't work properly, and was awfully hard to test (restarting Mathematica all the time)

A more-than-ideal answer would be a function to which you supply, say, Subscript[Ω, \[SelectionPlaceholder]] as an argument, and which generates the string to be put into the .tr file as result.

Side question: Is there a way to test the code later being put into the .tr file without restarting Mathematica all the time?

  • $\begingroup$ Here is an alternative solution: mathematica.stackexchange.com/q/164653/5478 $\endgroup$
    – Kuba
    Jun 14, 2019 at 5:22
  • 1
    $\begingroup$ Be careful. You should never modify core installation files. Copy them to the equivalent file in $UserBaseDirectory and edit that copy. $\endgroup$
    – b3m2a1
    Jun 14, 2019 at 6:18
  • $\begingroup$ Also, @b3m2a1 has a great package for the creation of custom KeyEvents! I’ll say also to avoid any combos that are superseded by the FrontEnd menus, too. They won’t work, or won’t work well. $\endgroup$ Jun 14, 2019 at 11:23

1 Answer 1


Why not use an InputAutoReplacements instead? For example:

CurrentValue[EvaluationNotebook[], {InputAutoReplacements, "ww"}] = "Ω"

Then you can type: w w Control+- to enter the desired subscript.

If you really want to use KeyEventTranslations.tr to do this, then you need to enter boxes:

Item[KeyEvent["O", Modifiers -> {Control, Command, Shift}],
            SubscriptBox["Ω", "\[SelectionPlaceholder]"],
  • $\begingroup$ What I settled for is InputAliases. The Omega with index was just a toy example, what I actually wanted is very similar to what is already existing, and which can be seen using CurrentValue[EvaluationNotebook[], InputAliases] $\endgroup$ Jun 14, 2019 at 11:17
  • $\begingroup$ Carl, the boxes method makes sense, so this should work for a combo of, say Ctrl+Alt/Cmd+’ for a SuperscriptBox["\[SelectionPlaceholder]","\[Prime]"] KeyEventTranslations? Same for Ctrl+Alt/Cmd+Shift+" and [DoublePrime]? Just checking for clarity. $\endgroup$ Jun 14, 2019 at 11:17
  • $\begingroup$ @Trevillian, yes that works, just tried it - I think I'm actually going to keep this in my KeyEventTranslations. $\endgroup$ Jun 14, 2019 at 11:44

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.