49

Some approaches are discussed in this question on StackOverflow. Original references to these go to Szabolcs's webpage and a MathGroup posting by Mr.Wizard. To summarize, you copy the file: $InstallationDirectory/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr to $UserBaseDirectory/ (with the same directory tree) and add the following ...


27

Superscript is not interpreted as Power: Presumably you are referring to what happens when you enter a power in superscript notation using the key combination Ctrl+6. Mathematica is capable of representing both this power notation and a formatted plain Superscript. In my opinion it is a failing that the power notation appears in the Typesetting menu while ...


26

Original answer Yes, with a bit of effort it is possible to construct such a package. My package Shortcuts, inspired by various questions and answers on this site over the years, can be installed in less than a minute from within a fresh notebook in Mathematica 9 or 10, on Windows, MacOSX or Linux by this Get@"http://goo.gl/aAxplX" or Get@"http://www....


23

You can see what can be done by running (maybe inspecting it in a browser first) Get["http://www.mertig.com/shortcuts.m"] This code will generate a modified copy of the default KeyEventTranslations.tr in : FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "TextResources", Switch[$OperatingSystem, "MacOSX", "Macintosh", "...


22

The short-cut keys for various actions can usually be found directly in the menu. Here on OS X you see the ⌘+/ at the right side under Un/Comment Selection: As pointed out in the comments for various systems the short-cuts to comment a selection are Mac OS X ⌘+/ Windows Alt+/ Right click + u which uses the context menu short-cut Linux Alt+/ Alt+Shift+...


21

You need to add the following to KeyEventTranslations.tr: Item[KeyEvent["Tab", Modifiers -> {Control}], FrontEndExecute[FrontEndToken["CycleNotebooksForward"]]], Item[KeyEvent["Tab", Modifiers -> {Shift, Control}], FrontEndExecute[FrontEndToken["CycleNotebooksBackward"]]], This will map Control-Tab and Control-Shift-Tab to cycling between ...


21

Here are four approaches to setting up keyboard shortcuts. The last is the best! AddMenuCommands First examples using notebook manipulation, (as you tried): This example adds a command to the Insert menu, with a key combination Control+U (normally the underline command). This addition just lasts for the session, but could be added to an init file. ...


20

Ah, figured it out: Panel @ DynamicModule[{input = ""}, Column[{TextCell["Enter your text here:"], EventHandler[ InputField[Dynamic[input], String, ContinuousAction -> True, FieldSize -> {40, 7}], "ReturnKeyDown" :> FrontEndExecute[{NotebookWrite[InputNotebook[], "\n", After]}] ], Dynamic@InputForm[input]}]]


20

I have this palette open all the time: CreatePalette@Row@ { Button["(\[SelectionPlaceholder])", FrontEndExecute[ FrontEndToken[SelectedNotebook[], "SelectionParenthesize"]]], Button["[\[SelectionPlaceholder]]", FrontEndExecute[ FrontEndToken[SelectedNotebook[], "SelectionBracket"]]], Button["{\[...


19

Referencing Szabolcs's answer, here is the code that must be added to KeyEventTranslations.tr: Item[KeyEvent["m", Modifiers -> {Control}], FrontEndExecute[{ FrontEnd`SelectionMove[FrontEnd`SelectedNotebook[], All, Cell], FrontEnd`FrontEndToken["Clear"] }]], I chose Ctrl+M at random; change it to whatever you want. See this ...


19

Do you mean CtrlShiftK? After typing Plo, press the key combination CtrlShiftK and a window will appear with possible options: As pointed by Yves,CtrlK will also work,but CtrlShiftK will work differently if you finish the function name. For an example, Type Plot3D; Use CtrlShiftK; Mathematica will show:


19

Shorthand notations: All those shorthand notations are well documented. For double struck letters like $\mathbb{A}$, use EscdsA, where ds stands for "double struck" For script letters like $\mathcal{A}$, use EscscAEsc, where sc stands for — you guessed it — "script". Creating your own aliases: To create your own aliases, use InputAliases. I use it to ...


19

Personally I would use what bill_s suggested, Ctrl+A followed by Shift+Enter. But if you want to have one shortcut you can use what Timothy linked. Just add this line to the KeyEventTranslations.tr file: Item[KeyEvent["h", Modifiers -> {Control}], FrontEndExecute[FrontEndToken[SelectedNotebook[ ], "EvaluateNotebook"]]] it works for me. Your ...


16

This will add Quit to Control+Q (and Alt+V Q Q): FrontEndExecute[ FrontEnd`AddMenuCommands["MenuListQuitEvaluators", {MenuItem["AddMenu &Quit", FrontEnd`KernelExecute[ToExpression["Quit[]"]], MenuKey["q", Modifiers -> {"Control"}], System`MenuEvaluator -> Automatic]}]] It only persists for the front end session. Usually I keep the ...


16

I usually press the down key until I get out of the cell, then press shift-up to select it. Here are two buttons that will select or delete the whole cell for you: select = Button["Select Cell", SelectionMove[SelectedNotebook[], All, Cell]] delete = Button["Delete Cell", SelectionMove[SelectedNotebook[], All, Cell]; FrontEndTokenExecute["Clear"]] ...


16

This is obsolete in Mathematica 9, which automatically includes contexts in completions. Undocumented function: use at your own risk, subject to change in future versions, etc.... The function you're interested in is FE`FC. It's been around for a while (here's a Mathematica Journal article that references it, near the end) although it has changed ...


16

Perhaps something like this?: DynamicModule[{key = ""}, EventHandler[ Dynamic[key], {"KeyDown" :> (key = CurrentValue["EventKey"])} ]]


15

Since you want this functionality to be able to insert aliases using the EscshortcutEsc syntax, you can edit the KeyEventsTranslation.tr file to achieve this. Copy the following file: $InstallationDirectory/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr or its equivalent on your system to $UserBaseDirectory/ (with the same directory ...


14

The keyboard shortcut for underscripts has now been changed to ctr-4 (ctr-$). So, to enter your Sum[expr, {n, 1, 10}], you should type escsumesc ctr-$n=1ctr-%10 ctr-spaceexpr Another option is to type the overscript ctr-& first and then use the ctr-% shortcut to move to the underscript position. Not all of the tutorials have been updated (and if you ...


14

Try using this: FrontEndExecute[ {FrontEnd`NotebookFind[FrontEnd`SelectedNotebook[], "Output", All, CellStyle, AutoScroll->False], FrontEnd`FrontEndToken["Clear"]}] (Untested in KeyEventTranslations.tr, but works as a button!) Regarding automating confirming the dialog---I don't think it is possible from within ...


14

In this context it might be useful to remark that if you enter escsumtesc you'll get a complete sum template with your cursor already at the bottom: I feel this is much easier than going through the other shortcuts. The same works for products: escprodtesc indefinite integrals: escinttesc and definite integrals: escdinttesc The 't'-s at the end of ...


14

Changing shortcuts isn't that complicated. All you have to do is change one line in the file KeyEventTranslations.tr in a location in your file system specified by this command: FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources", $OperatingSystem}] Locate the following line in a text editor and change the key into the one ...


14

Here is the answer given by Rolf Mertig that includes many additional shortcuts. One of them Ctrl+t, evaluates whatever is stored in joker.m file (invoked by Ctrl+Shift+J). There are already two examples, coincidentally the second one is exactly what you need: NotebookApply[SelectedNotebook[], RowBox[{"\"", "\[SelectionPlaceholder]", "\""}], Before] Ok, ...


13

Besides the nice real handy option suggested by @yulinlinyu (more here) you can also use text-based interface to find completion for your half-typed function. It is not that fast, but has its own advantages. Try executing this: ?Plot* and you'll get this nice table of possible functions that complete your input. If you click on any you'll get short ...


13

Thanks to everyone for the helpful comments. Here's the exact procedure I used to fix this (specific to Mac OS X, version 10.8 if that matters, and Mathematica 8, but it should be analogously applicable to other versions and operating systems): Close Mathematica Delete the keymap cache. For me this was in ~/Library/Mathematica/FrontEnd/8.0 Caches/MacOSX-...


13

For OSX you can do the following. Select Mathematica. Click on "Mathematica" menu then "Services -> Services Preferences..." Select "Shortcuts" tab. In the left side select "App Shortcuts". Click the + button. Fill out the following. Click add after you have set your short cut key and you are good to go.


13

I think you're looking for the menu item Edit | Check Balance or the equivalent keyboard short-cut Shift + Cmd + B.


12

Edit the KeyEventTranslations.tr file in a plain text editor by adding the following definitions to the first section of the file: EventTranslations[{ (* Custom shortcuts *) Item[KeyEvent["[",Modifiers->{Control}], FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], "[\[SelectionPlaceholder]]"],FrontEndToken["...


12

To clarify the situation: In Version 9 on Windows and OS X, there is a new Make Template system which supports multiple templates for built-in functions. As part of the new system, unfortunately a bug was introduced which makes it ignore the usage statement for user-defined functions. This bug has been confirmed and we hope to fix it in a future release, ...


12

Following detects backspace on Mac: SetOptions[EvaluationNotebook[],NotebookEventActions-> {{"KeyDown","\.08"}:>Print["triggered"]}] This code can be helpful for finding out different codes for non-standard keys. SetOptions[EvaluationNotebook[],NotebookEventActions-> {"KeyDown":>Print[FullForm@CurrentValue["EventKey"]]}]


Only top voted, non community-wiki answers of a minimum length are eligible