Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

Performing Desktop Actions Using Keyboard Shortcuts

Overview

A keyboard shortcut is a means of using keyboard key strokes to perform a desktop action, without opening a desktop menu. If a keyboard shortcut is available for a menu option, it appears to the right of the option name on the menu. For example, the default keyboard shortcut for opening the Open dialog box is Ctrl+O.

It is possible to have multiple keyboard shortcuts for an action. All defined shortcuts work, but only one appears next to the option name on the desktop menu. When you provide a keyboard shortcut for a menu option that previously had none, the desktop menu automatically updates to display the keyboard shortcut.

If you define a keyboard shortcut that uses the same keystrokes as a mnemonic but performs a different action, then the mnemonic no longer works.

You can choose from a set of shortcuts that install with MATLAB, create custom shortcut sets, or use shortcut sets copied from other users or systems. For more information see Performing Desktop Actions Using the Keyboard

Choosing a Set of Keyboard Shortcuts

You choose a set of keyboard shortcuts to use from the Active settings drop-down list in the Keyboard Shortcuts preferences dialog box. By default, MATLAB uses a settings file that corresponds to the platform on which you are running. Use the default keyboard shortcuts set or use a different set to:

To choose a keyboard shortcuts settings file, follow these steps:

  1. Open the Keyboard Shortcuts Preferences dialog box by choosing File > Preferences > Keyboard > Shortcuts.

  2. Click the down arrow in the Active settings field, and then choose a settings file that you want to use.

    If a file that you want to use is on your system, but does not appear in the drop-down list, click Browse to find it.

  3. Click Apply.

Keyboard Shortcuts Settings Files

The following table lists the keyboard shortcuts settings files installed with MATLAB.

Operating SystemKeyboard shortcut settings files installed with MATLAB
Windows
  • Windows Default Set (Default)

    Specifies MATLAB keyboard shortcuts for the Windows operating system across the desktop.

  • Emacs Default Set

    Specifies Emacs keyboard shortcuts across the MATLAB desktop.

  • R2009a Windows Default Set

    Restores the MATLAB default keyboard shortcuts that were in place for the Windows platform in Version 7.9 (R2009a) and earlier releases.

    In those releases, this set of keyboard shortcuts appeared on the Keyboard Preferences pane as a combination of Command Window key bindings and Editor/Debugger key bindings, as shown in the following image.

UNIX
  • Emacs Default Set (Default)

    Specifies Emacs keyboard shortcuts across the MATLAB desktop.

  • Windows Default Set

    Specifies MATLAB keyboard shortcuts for the Windows operating system across the desktop.

  • R2009a UNIX Default Set

    Restores the MATLAB default keyboard shortcuts that were in place for the UNIX platforms in Version 7.9 (R2009a) and earlier releases (not including the Macintosh platform).

    In those releases, this set of keyboard shortcuts appeared on the Keyboard Preferences pane as a combination of Command Window key bindings and Editor/Debugger key bindings, as shown in the following image.

Macintosh
  • Macintosh Default Set (Default)

    Specifies MATLAB keyboard shortcuts for the Macintosh operating system across the desktop.

  • R2009a Macintosh Default Set

    Restores the MATLAB default keyboard shortcuts that were in place for the Macintosh platform in Version 7.9 (R2009a) and earlier releases.

    In those releases, this set of keyboard shortcuts appeared on the Keyboard Preferences pane as a combination of Command Window key bindings and Editor/Debugger key bindings, as shown in the following image.

Identifying Keyboard Shortcuts

To determine the current keyboard shortcut for an action, view one of the following:

Keyboard Shortcuts on Menus

Open the menu to see if the keyboard shortcut appears next to the menu option.

For example, suppose you want to determine the keyboard shortcut for decreasing the indent in the Editor. Open the Text menu, and then view the keyboard shortcut for Decrease Indent. The keyboard shortcut Ctrl+[ appears to the right of the option.

If no keyboard shortcut appears on the menu, one does not currently exist for that action. To create a keyboard shortcut for an action, follow the steps in Customizing Keyboard Shortcuts.

Keyboard Shortcuts on the Keyboard Shortcuts Preferences Pane

To identify a keyboard shortcut when there is no menu option for an action, use the Keyboard Shortcuts Preferences pane:

  1. Choose File > Preferences > Keyboard > Shortcuts.

  2. In the filter field, type the name of the tool for which you want to list the keyboard shortcuts. For example, type Editor to see the keyboard shortcuts currently defined for actions you can perform in the Editor.

  3. Narrow the list of Action names that the preferences pane displays by typing a string describing the action. For example, type clear, if you want to find the keyboard shortcut for clearing selected text in the Editor. Type a short string to increase the likelihood of the filter returning the action you seek.

  4. View the table that appears in the middle of the Keyboard Shortcuts Preferences pane. For example, this table indicates that the Escape key is the current keyboard shortcut for the Clear Selection action in the Editor.

Customizing Keyboard Shortcuts

To customize or view keyboard shortcuts for MATLAB desktop tools, choose File > Preferences > Keyboard > Shortcuts. If you have an active Internet connection, you can watch the Customizable Keyboard Shortcuts video for an overview.

The following sections provide details:

Steps for Customizing Keyboard Shortcuts

  1. Choose File > Preferences > Keyboard > Shortcuts.

  2. In the Active settings field, choose the file that contains the set of keyboard shortcuts that you want to customize.

    Typically, the first time you modify keyboard shortcuts, you begin with the default settings for your platform. For details, see Choosing a Set of Keyboard Shortcuts.

  3. Under Action name, select the action for which you want to define or modify a keyboard shortcut. An action is the operation for which you want to customize the shortcut, such as Clear Command History.

    For tips on finding the action you want, see Filtering Keyboard Shortcut Actions.

  4. Click the Add button .

    An editable field opens under the Shortcut column.

  5. Type the shortcut that you want to use for the action you selected in Step 3. Alternatively, you can choose a shortcut from the drop-down menu.

    For details, see Specifying Keystrokes for a Keyboard Shortcut.

  6. Assign the shortcut to the tool or tools with which you want to use it. For example, in the Tools with shortcut column:

    1. Click the down arrow for the list of desktop tools to which you can assign a shortcut. Not all actions are available with all desktop tools.

    2. Select a check box to assign the shortcut to a tool. Clear a check box to remove it.

  7. Evaluate and resolve conflicts, indicated by the informational and error icons, if necessary.

    For more information, see Evaluating and Resolving Keyboard Shortcut Conflicts.

  8. Click Apply.

    • The keyboard shortcut becomes available immediately.

    • If you changed a shortcut that corresponds to a menu option that previously did not display a keyboard shortcut, MATLAB reflects the new keyboard shortcut in the menu.

Restoring Default Sets

If you modify keyboard shortcuts, and then decide you do not want to keep the changes, click Restore defaults. Be aware that clicking Restore defaults reverts all keyboard shortcuts changes you have made since you last saved the set. If you modify keyboard shortcuts in a set that installs with MATLAB, such as Windows Default, you lose all previous modifications. You cannot revert changes on a shortcut-by-shortcut basis.

The following image shows the Active settings field displaying a modified Windows Default set of keyboard shortcuts and the Restore defaults button.

Saving Keyboard Shortcuts to a Settings File

Save a settings file to:

To save a keyboard shortcuts settings file, follow these steps:

  1. Open the Keyboard Shortcuts Preferences dialog box by choosing File > Preferences > Keyboard > Shortcuts.

  2. Click the Save As button.

  3. Navigate to the folder in which you want to save the file, specify the file name, and then click Save.

    MATLAB saves the file as an .xml file in the folder that the Command Window returns when you type prefdir.

Filtering Keyboard Shortcut Actions

Use the filter field to see the list of actions for which you can customize or define a keyboard shortcut as follows:

  1. Type all or part of any one of the following:

    • An action name, for example, Delete.

      MATLAB displays only the action names or desktop menus that contain the text you specify.

    • The name of a desktop tool or menu, for example, File or Command Window.

      MATLAB displays the action names associated with the tool or menu you specify. In addition, the list of action names includes any action names that contain the name of the tool or menu. For example, if you specify Command History, the list of action names includes Next History Command, which is a Command Window action.

    • A keyboard shortcut, for example, Ctrl+R

      MATLAB displays only the action names that have the shortcut you specify. Be aware of the following:

      • You can enter most keyboard shortcuts by either pressing the keystrokes or typing the key names.

        To specify Ctrl+S, for example, you can type Ctrl+S character-by-character, or you can press the keyboard shortcut, Ctrl+S.

      • If pressing the keystrokes for a keyboard shortcut does not work, try typing it instead. Some examples of keyboard shortcuts you must type character-by-character are Tab, Backspace, and Delete.

      • Use NumPad to refer to the number pad that is on the far right of some keyboards.

      • Use Up and Down to refer to the Up arrow and Down arrow keypad keys.

  2. Verify that an Action name performs the action you expect:

    1. Hover the mouse pointer over the Action name. For example, Remove Next Word.

    2. View the tooltip that appears.

Specifying Keystrokes for a Keyboard Shortcut

Specify the keystrokes for a keyboard shortcut as follows:

  1. Click the Add button

  2. Specify the number of keystrokes you want to use for the shortcut.

    • To use the default, which is one keystroke, skip to step 3.

    • To specify multiple keystrokes, or to specify explicitly one keystroke follow these steps:

      1. Click the down arrow next to the key icon in the Shortcuts field.

      2. Choose Limit to 1 keystroke, Limit to 2 keystrokes, or Limit to 3 keystrokes.

        For instance, Ctrl+F is one keystroke, Ctrl+Y, Shift+Z is two keystrokes, and Ctrl+Y, Shift+Z, F9 is three keystrokes.

  3. Specify the keystrokes, by doing one of the following:

    • Type the keystrokes, by pressing the keys, not spelling the key names.

      For example, press the Ctrl key and the Y key. Do not type C-t-r-l-+-Y.

    • Choose a keystroke such as the Tab key, by clicking the down arrow next to the key icon in the Shortcuts field. Then, choose the key name.

      The listed keys are those keys that already have a defined action within a dialog box. For example the Tab key navigates from one field to the next in a dialog box.

Evaluating and Resolving Keyboard Shortcut Conflicts

Conflicts arise when the same shortcut is assigned to two or more different actions. There is no requirement that you resolve keyboard shortcut conflicts. However, if the same shortcut specifies two different actions, the shortcuts can be confusing to use.

View keyboard shortcut conflicts by choosing File > Preferences > Keyboard > Shortcuts.

The Keyboard Shortcuts preferences pane indicates conflicts using informational and error icons.

Actions in Different Tools Have the Same Shortcut — Evaluating Conflicts

Typically, you want to resolve conflicts indicated by the informational icon when all the following are true:

For instance on Microsoft Windows platforms, by default, Ctrl+Shift+U undocks a tool from the MATLAB desktop. However if you select text in the Editor, and then press Ctrl+Shift+U, it changes the selected text to uppercase. If you frequently use both of these actions, you can specify a different keyboard shortcut for one or both actions.

Actions in the Same Tool Have the Same Shortcut — Evaluating Conflicts

Typically, you want to resolve conflicts indicated by the error icon .

It can be unnecessary to resolve these conflicts if one or more of the following are true:

Resolving Keyboard Shortcut Conflicts

To resolve a conflict, change or delete shortcuts such that there is a one-to-one correspondence between a shortcut and a frequently used action. For examples, see Changing a Keyboard Shortcut and Deleting a Keyboard Shortcut.

Examples of Creating, Modifying, and Deleting Keyboard Shortcuts

Creating a New Keyboard Shortcut

By default, no keyboard shortcut is available for adding a Help topic to the list of favorites. If you frequently mark topics as favorites, you can define a keyboard shortcut for this action, as follows:

  1. Choose File > Preferences > Keyboard > Shortcuts.

  2. In the filter field, type Help.

  3. Scroll through the Action name list, and select Add to Favorites.

  4. Click the plus button

    MATLAB adds a row to the table above the plus button.

  5. In the Shortcut field, click the down arrow, and then change Limit to 1 keystroke to Limit to 2 keystrokes.

  6. In the Shortcut field, press Ctrl+S, and then Alt+V.

    Notice that the All Possible Conflicts table is empty, which indicates that no other desktop action is currently using this combination of keystrokes.

  7. Click Apply.

Notice that:

Changing a Keyboard Shortcut

Suppose you frequently adjust indenting in the MATLAB Editor. However, you have difficulty remembering the default keyboard shortcut of Ctrl+[ for decreasing the indent. So, you decide to change it to something that is easier to remember.

This example changes the keyboard shortcut for Decrease Indent in the MATLAB Editor from Ctrl+[ to Ctrl+Backspace:.

  1. Choose File > Preferences > Keyboard > Shortcuts.

  2. Under Active settings, choose Windows Default Set.

  3. In the filter field, press Ctrl+[.

    Under Action name, Decrease Indent displays in shading.

  4. In the table labelled Click in the table below to edit shortcuts for Decrease Indent, under Shortcut, click Ctrl+[. MATLAB makes the field editable.

  5. In the Shortcut field, press Ctrl+Backspace.

  6. Click Apply.

    MATLAB saves your changes to the Windows Default Set (modified) settings.

Deleting a Keyboard Shortcut

Suppose you find yourself frequently pressing the wrong keyboard shortcut. For example, you press Alt+Enter (apply M-Lint autofix) instead of Ctrl+Enter (evaluate the current cell in the MATLAB Editor ). To avoid accidentally applying an M-Lint autofix, you decide to delete the Alt+Enter shortcut. Follow these steps:

  1. Choose File > Preferences > Keyboard > Shortcuts.

  2. Under Active settings, choose Windows Default Set or Windows Default Set (modified).

  3. In the filter field, press Alt+Enter.

  4. Under Action name, select the row containing Autofix M-Lint.

  5. In the next table, under Shortcut, select the row containing Alt+Enter.

  6. Click the remove button .

  7. Click Apply.

    If it does not exist, MATLAB creates a Windows Default Set (modified) keyboard shortcut set. This set consists of the Windows Default Set of keyboard shortcuts, less the shortcut for Alt+Enter. If the Windows Default Set (modified) settings file exists, then MATLAB deletes the Alt+Enter keyboard shortcut from that set of keyboard shortcuts.

Using Keyboard Shortcuts Settings Files Created on Other Systems

If you find a keyboard shortcuts settings file that is useful to you, or if you want to use one you created on a different system, make it the active keyboard shortcuts settings file as follows:

  1. Copy the settings file to a folder on your system, such as:

    I:\my_matlab_files\active_settings_files\new_settings.xml
  2. Choose File > Preferences > Keyboard > Shortcuts.

  3. In the Active settings field, click the down arrow, and then click Browse.

  4. In the Open dialog box, navigate to the folder where you copied the settings file.

  5. Select the settings file, and then click Open.

  6. In the Keyboard Shortcuts preferences pane, click Apply. The settings file you specified is now the active settings file for MATLAB.

Consider using File Exchange to share your active settings file with others, or to find a file that is useful to you. For more information on File Exchange, see File Exchange — Finding and Getting Files Created by Other Users.

Keyboard Shortcut Restrictions

These sections describe the tools, portions of tools, and actions for which you cannot change keyboard shortcuts:

Tools for which You Cannot Customize Keyboard Shortcuts

You cannot change the keyboard shortcuts associated with the following tools or portions of tools:

Actions for Which You Cannot Customize Keyboard Shortcuts

The following table describes some frequently used actions for which you cannot customize keyboard shortcuts.

Action

Keyboard Shortcut

Cancel the current action.

Esc (escape)

For example, if you select the Edit menu, the menu items display. Pressing Esc retracts the menu items.

In the Function Browser, pressing Esc up to three times has the following effects:

  1. Dismisses the search history

  2. Clears the search field

  3. Closes the Function Browser

Interrupt MATLAB execution on all supported platforms.

Ctrl+C

Interrupt MATLAB execution on Windows and UNIX systems.

Ctrl+Cancel

Interrupt MATLAB execution on Macintosh systems.

Cmd+. (period)

Open context menu on Windows and UNIX systems.

Ctrl+Shift+F10

Close the desktop and consequently shut down the MATLAB program. Outside the desktop, close the active window (except on Macintosh platforms).

Alt+F4

Accessibility affordances

Tab for navigating through fields in dialog boxes, for example.

Make an open tool the active tool

These shortcuts appear on the desktop Windows menu. They are:
  • Command History: Ctrl+1

  • Command Window: Ctrl+0

  • Current Folder: Ctrl+2

  • Editor: Ctrl+Shift+0

  • Figures: Ctrl+Shift+1

  • Figure Palette: Ctrl+7

  • File and Folder Comparisons: Ctrl+Shift+4

  • File Exchange: Ctrl+6

  • Help: Ctrl+4

  • Plot Browser: Ctrl+8

  • Profiler: Ctrl+5

  • Variable Editor: Ctrl+Shift+3

  • Web Browser: Ctrl+Shift+2

  • Workspace: Ctrl+3

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS