MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Keyboard shortcuts

  • To: mathgroup at
  • Subject: [mg23091] Re: Keyboard shortcuts
  • From: "Atul Sharma" <atulksharma at>
  • Date: Sun, 16 Apr 2000 00:37:32 -0400 (EDT)
  • References: <8d96sb$>
  • Sender: owner-wri-mathgroup at

Some time ago, Paul Hinton of WRI was kind enough to forward a recipe for
remapping the keyboard. I enclose it here:

A. Sharma
Atul Sharma MD, FRCP(C)
Pediatric Nephrologist,
McGill University/Montreal Children's Hospital

Under Mathematica 3.0 and 4, keystroke sequences are associated with
actions by way of a Mathematica text resource file named

The file is installed deep within the core Mathematica tree in the

ToFileName[{$TopDirectory, "SystemFiles", "FrontEnd", "TextResources"}]

because Microsoft Windows uses different keymapping conventions, a
platform-specific version of this file can be found in:

ToFileName[{$TopDirectory, "SystemFiles", "FrontEnd", "TextResources",

The structure of the file looks something like this:

[begin file schematic]
@@resource KeyEventTranslations

EventTranslations[<list of Item[] expressions>]
[end file schematic]

An individual Item[] expression contains two arguments.

Item[KeyEvent[<event name>], <front end action>]

The argument to KeyEvent[] is a key name.  Alphanumeric keys are
represented as strings.  Function and motion keys are referred to by
symbols that usually parallel their labeled name.  For example, the act of
typing the K key by itself is represented as


However, a key such as the right arrow cursor movement key will look like


Most of the non-alphanumeric keys are associated with events in, so it is probably no necessary for you to guess
at the key's name.

KeyEvent[] expressions support two options.

Modifiers, which takes a list of modifier key names as its value.  These
are keys that must also be depressed with the primary key to acutate the
event.  For example, to denote Ctrl-I, you could enter the following:

KeyEvent["i", Modifiers -> {Control}]

Modifier key names are Shift, Control, Command, and Option.  On a
Macintosh, these map to keys with the same name.  Under X Window, Command
maps to Mod1 and Option maps to Mod2.  On Microsoft Windows, Command maps
to the Alt key, and the Control key maps to itself.

If you want an action to take place only within a cell that uses
two-dimensional boxes (StandardForm or TraditionalForm), then you can add
an option named CellClass and give it the value BoxFormData.  In this
example, pressing Ctrl-Left Arrow will apply only in cells which use
StandardForm or TraditionalForm.  It will not apply to plain text cells or

KeyEvent[Left, Modifiers -> {Control}, CellClass -> BoxFormData]

The action that appears in the second argument can be either a command
token in the form of a string (e.g. "CreateInlineCell"), or a function
that contains only front end manipulation functions.

The actions listed in the Item[] expressions of
should give you a clue as to some of the tokens available.  You can also
look in the directory

ToFileName[{$TopDirectory, "SystemFiles",
   "FrontEnd", "TextResources",
   LinkWrite[$ParentLink, FrontEnd`Value["$SystemID"]];

for a file named  A similar mechanism allows the association
of menu item listings and front end commands.

A more exhaustive listing of front end command tokens can be found in
Chapter 56 of the book _The Beginner's Guide to Mathematica Version 3_ by
Jerry Glynn and Theodore Gray.

Let's now work through an example.  Suppose we wanted to define a keyboard
shortcut for initiating the File -> Save As Special -> EPS menu command
and map it to Ctrl-q.  Here is what the item may look like.

KeyEvent["q", Modifiers -> {Control}],

The three-argument form of FrontEndToken[] is documented in Gray and
Glynn.  This is probably one of the more complicated examples that one
could devise.

If you do not have the necessary permissions to edit the file, you can create a folder with path:

ToFileName[{$PreferencesDirectory, "SystemFiles",
   "FrontEnd", "TextResources",
   LinkWrite[$ParentLink, FrontEnd`Value["$SystemID"]];

and then copy the file from your Mathematica
installation into your newly created directory.  Make your changes to that
file, and they will apply only to your own setup.

Felix E. Klee wrote in message <8d96sb$ii3 at>...
>I would like to change the keyboard short cuts in Mathematica 4
>for Linux.
>Where can I find information on how to do it?

  • Prev by Date: Re: breaking up lists into intervals
  • Next by Date: Plotting bounded domains
  • Previous by thread: Re: Keyboard shortcuts
  • Next by thread: Equivalent to Mesh->False in ParametricPlot3D?