TransWikia.com

How to add a keyboard shortcut to open a Palette

Mathematica Asked by divenex on May 28, 2021

I would like to add a hotkey or keyboard shortcut to open a Mathematica Palettte, like e.g. the Basic Math Assistant. I found a number of questions like this one or this one with answers suggesting to make changes to the KeyEventTranslations.tr file. But I could not figure out how to apply these ideas to make a shortcut for a general menu command.

The path of the file KeyEventTranslations.tr can be found with the following command

FileNameJoin[{$InstallationDirectory, "SystemFiles/FrontEnd/TextResources", $OperatingSystem}]

For example, on Windows, the file location would be like

"C:Program FilesWolfram ResearchMathematica12.2SystemFilesFrontEndTextResourcesWindows"

One Answer

(* Palettes *)
    Item[KeyEvent["x", Modifiers -> {Control, Shift}],
        FrontEndExecute[{
            FrontEnd`FrontEndToken[
                "OpenFromPalettesMenu",
                "BasicMathAssistant.nb"
        ]}
    ]],

Adding the code above into KeyEventTranslations.tr, restart Mathematica, then you can use Control+Shift+x to open BasicMathAssistant.

Here you can find out all the FrontEndToken that we can use.

Correct answer by Chromo Runge on May 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP