Customizing Mathematica shortcuts

Here is a nice article.

Also, FROM HERE (unchecked)

Question:
How do I modify the front end to add new keyboard shortcuts?
Answer:
(mathgroup May 2005, trevor baca:)

I’ve been mucking around in KeyEventTranslations.tr setting up keyboard shortcuts recently and i’ve learned that front end tokens are pretty cool. this wolfram page gives pretty good docs.

Anyway, here are three that i had to work a little to get going (with good help from the mathgroup, as always).

  • for a quit kernel keyboard shortcut, add the following to KeyEventTranslations.tr:
       Item[KeyEvent["q", Modifiers -> {Control, Option}],
               FrontEndExecute[
                       FrontEndToken[
                                SelectedNotebook[ ],
                                "EvaluatorQuit",
                                Automatic
                       ]
               ]
       ]  

  • for an initialization cell toggle keyboard shortcut (repeated from previous thread), add the following to KeyEventTranslations.tr:
      Item[KeyEvent["i", Modifiers -> {Command, Control}],
               FrontEndExecute[
                       FrontEndToken[
                               SelectedNotebook[ ],
                               "InitializationCell",
                               "Toggle"
                       ]
               ]
       ]  
  • for a save as package keyboard shortcut, add the following to KeyEventTranslations.tr:
       Item[KeyEvent["k", Modifiers -> {Control, Option}], 
           SaveRenameSpecial["Package"]]

Edit

I found a full list of the (undocumented) front-end tokens. Hope you’ll understand that these are unsupported!

{"AllWindowsFront", "BackgroundDialog", "Balance", "BringToFront",
"CellContextDialog", "CellGroup", "CellLabelsToTags", "CellMerge",
"CellSplit", "CellTagsEditDialog", "CellTagsEmpty", "CellTagsFind",
"CellUngroup", "Clear", "ClearCellOptions", "ClearNoAutoScroll",
"Close", "CloseAll", "CloseMain", "ColorSelectorDialog",
"ColorsPanel", "CompleteSelection", "Copy", "CopyCell",
"CopySpecial", "CreateCounterBoxDialog", "CreateGridBoxDialog",
"CreateHyperlinkDialog", "CreateInlineCell", "CreateValueBoxDialog",
"Cut", "CycleNotebooksBackward", "CycleNotebooksForward",
"DebuggerAbort", "DebuggerClearAllBreakpoints", "DebuggerContinue",
"DebuggerContinueToSelection", "DebuggerFinish",
"DebuggerResetProfile", "DebuggerShowProfile", "DebuggerStep",
"DebuggerStepIn", "DebuggerStepInBody", "DebuggerStepOut",
"DebuggerToggleBreakpoint", "DebuggerToggleWatchpoint",
"DeleteGeneratedCells", "DeleteIndent", "DeleteInvisible",
"DuplicatePreviousInput", "DuplicatePreviousOutput",
"EditStyleDefinitions", "EnterSubsession", "Evaluate",
"EvaluateCells", "EvaluateInitialization", "EvaluateNextCell",
"EvaluateNotebook", "EvaluatorAbort", "EvaluatorHalt",
"EvaluatorInterrupt", "EvaluatorQuit", "EvaluatorStart",
"ExitSubsession", "ExpirationDialog", "ExplainBeepDialog",
"ExplainColoringDialog", "ExpressionLinewrap", "FileNameDialog",
"FindDialog", "FindEvaluatingCell", "FindNextMisspelling",
"FindNextWarningColor", "FinishNesting", "FixCellHeight",
"FixCellWidth", "FontColorDialog", "FontFamilyB", "FontPanel",
"FontSizeDialog", "FrontEndHide", "FrontEndQuit",
"FrontEndQuitNonInteractive", "GenerateImageCaches",
"GenerateNotebook", "GeneratePalette", "GraphicsAlign",
"GraphicsCoordinatesDialog", "GraphicsOriginalSize",
"GraphicsPlotRangeAll", "GraphicsPlotRangeAutomatic",
"GraphicsPlotRangeFixed", "GraphicsRender", "Group",
"HandleShiftReturn", "HeadersFootersDialog", "HelpDialog",
"HyperlinkGo", "HyperlinkGoBack", "HyperlinkGoForward", "Import",
"ImportPictures", "ImportStyleDefinitions", "Indent",
"InsertClipPlane", "InsertMatchingBraces", "InsertMatchingBrackets",
"InsertMatchingParentheses", "InsertNewGraphic", "InsertObject",
"InsertRawExpression", "InsertSoftReturn", "LicAuthFailureDialog",
"MacintoshOpenDeskAccessory", "MenuListBoxFormFormatTypes",
"MenuListCellEvaluators", "MenuListCellTags",
"MenuListCommonDefaultFormatTypesInput",
"MenuListCommonDefaultFormatTypesInputInline",
"MenuListCommonDefaultFormatTypesOutput",
"MenuListCommonDefaultFormatTypesOutputInline",
"MenuListCommonDefaultFormatTypesText",
"MenuListCommonDefaultFormatTypesTextInline",
"MenuListConvertFormatTypes", "MenuListDisplayAsFormatTypes",
"MenuListExportClipboardSpecial", "MenuListFonts",
"MenuListFontSubstitutions", "MenuListGlobalEvaluators",
"MenuListHelpWindows", "MenuListNotebookEvaluators",
"MenuListNotebooksMenu", "MenuListPackageWindows",
"MenuListPalettesMenu", "MenuListPaletteWindows",
"MenuListPlayerWindows", "MenuListPlugInCommands",
"MenuListPrintingStyleEnvironments", "MenuListQuitEvaluators",
"MenuListRelatedFilesMenu", "MenuListSaveClipboardSpecial",
"MenuListScreenStyleEnvironments", "MenuListStartEvaluators",
"MenuListStyleDefinitions", "MenuListStyles",
"MenuListStylesheetWindows", "MenuListTextWindows",
"MenuListWindows", "ModifyBoxFormFormatTypes",
"ModifyDefaultFontProperties", "ModifyEvaluatorNames",
"ModifyFontSubstitutions", "ModifyNotebooksMenu",
"ModifyRelatedFiles", "MoveBackward", "MoveForward", "MoveToBack",
"MoveToFront", "New", "NewPackage", "NewText",
"NextFunctionTemplate", "NotebookMail", "NotebookMailSelection",
"NotebookOneNote", "NotebookOneNoteSelection",
"NotebookStatisticsDialog", "Open", "OpenCloseGroup",
"OpenFromNotebooksMenu", "OpenFromNotebooksMenuEmpty",
"OpenFromPalettesMenu", "OpenFromRelatedFilesMenu", "OpenHelpLink",
"OpenSelection", "OpenSelectionParents", "OpenURL", "OptionsDialog",
"PasswordDialog", "Paste", "PasteApply", "PasteApplyNoAutoScroll",
"PasteDiscard", "PasteDiscardNoAutoScroll", "PasteSpecial",
"PlainFont", "PreferencesDialog", "PreviousFunctionTemplate",
"PrintDialog", "PrintOptionsDialog", "PrintSelectionDialog",
"PublishToPlayer", "RebuildHelpIndex", "RecordSoundDialog",
"RefreshDynamicObjects", "RelatedFilesMenu",
"RemoveFromEvaluationQueue", "Replace", "ReplaceAll", "ReplaceFind",
"ReplaceParent", "Revert", "RunColorDialog", "RunEdgeColorDialog",
"RunFaceColorDialog", "Save", "SaveRename", "SaveRenameSpecial",
"ScrollLineDown", "ScrollLineUp", "ScrollNotebookEnd",
"ScrollNotebookStart", "ScrollPageBottom", "ScrollPageDown",
"ScrollPageFirst", "ScrollPageLast", "ScrollPageNext",
"ScrollPagePrevious", "ScrollPageTop", "ScrollPageUp",
"SelectGeneratedCells", "SelectionAnimate", "SelectionBrace",
"SelectionBracket", "SelectionCloseAllGroups",
"SelectionCloseUnselectedCells", "SelectionConvert",
"SelectionConvertB", "SelectionDisplayAs", "SelectionDisplayAsB",
"SelectionHelpDialog", "SelectionOpenAllGroups",
"SelectionParenthesize", "SelectionSaveSpecial", "SelectionScroll",
"SelectionSetFind", "SelectionSpeak", "SelectionSpeakSummary",
"SelectionUnbracket", "SelectNotebookWindow", "SetDefaultGraphic",
"SimilarCellBelow", "SoundPlay", "SpellCheckerDialog",
"StackWindows", "Style", "StyleDefinitionsOther", "StyleOther",
"SubsessionEvaluateCells", "SystemPrintOptionsDialog",
"TemplateSelection", "TestEvaluateNotebook", "TileWindowsTall",
"TileWindowsWide", "ToggleDebugFlag", "ToggleDynamicUpdating",
"ToggleGrayBox", "ToggleOptionListElement", "ToggleShowExpression",
"ToggleTestingFlag", "TrustNotebook", "Undo", "Ungroup",
"WindowMiniaturize", "XInfoDialog", "ZoomWindow"}

Leave a Comment