Documentation Center

  • Trial Software
  • Product Updates

Define Keyboard Shortcuts

Keyboard Shortcuts

To quickly access desktop features, you can use keyboard shortcuts. Press Alt to display tooltips on MATLAB® Toolstrip buttons, indicating what keys to press to access those features. For example, pressing Alt followed by H accesses the Home tab and displays tooltips for the features available on that tab. You cannot customize these shortcuts.

An action can have multiple keyboard shortcuts. All defined shortcuts work, but only one appears on the desktop Toolstrip tooltip.

You can:

  • Choose from a set of shortcuts that install with MATLAB.

  • Create customized sets of shortcuts.

  • Use a set of shortcuts copied from another system

Choose a Set of Keyboard Shortcuts

By default, MATLAB uses keyboard shortcut settings that correspond to the platform on which you are running. To choose different keyboard shortcut settings, follow these steps:

  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard > Shortcuts.

  2. Click the down arrow in the Active settings field, and make a selection from the drop-down list, as summarized in this table.

    Settings File Option to SelectDetails

    Installed with MATLAB

    • On Mac, Mac Default Set

    • On all other systems, Windows Default Set or Emacs Default Set

    For a description of the files that install with MATLAB, see Installed Settings Files for Keyboard Shortcuts.

    Previously added

    The file name

    No additional information.

    On your system, but not in the drop-down list

    Browse

    Browse to Keyboard Shortcuts Settings Files.

  3. Click Apply.

Installed Settings Files for Keyboard Shortcuts

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)

  • Emacs Default Set

UNIX®
  • Emacs Default Set (Default)

  • Windows Default Set

Macintosh
  • Macintosh Default Set (Default)

Browse to Keyboard Shortcuts Settings Files

Browse to use a keyboard shortcuts settings file that is on your system, but not an Active settings choice in the Keyboard Shortcuts Preferences dialog box. This situation typically arises when you copy a settings file from another system to a folder other than the prefdir directory. To browse to a settings file and make it your active settings file, follow these steps:

  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard > Shortcuts.

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

  3. In the Open dialog box, navigate to the folder containing the settings file.

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

  5. In the Keyboard Shortcuts preferences pane, click OK.

    The settings file you selected in step 4 is now the active settings file for MATLAB.

Future MATLAB sessions will provide this settings file as a choice in the Active settings drop-down menu.

Use Keyboard Shortcut Settings Files from File Exchange

Download keyboard shortcut settings files from File Exchange when you want to do either of the following:

  • Restore the MATLAB default keyboard shortcuts that were in place for MATLAB Version 7.9 (R2009a) and earlier releases.

  • Find and download keyboard shortcuts that others created and uploaded to File Exchange.

Follow these steps:

  1. Search the File Exchange Web site for the keyboard shortcut set that you want to use. Files tagged with keyboard shortcuts configurable include:

    • MATLAB Desktop R2009a Non-Default Keyboard Shortcut sets

    • MATLAB Desktop R2009a Default Keyboard Shortcut sets

  2. Click the name of the file submission to view a description of the file.

  3. Click the Download Submission button and save the .ZIP file to your computer.

  4. In the MATLAB Current Folder browser, navigate to the location of your saved file. Right-click the downloaded .ZIP file, and then select Extract.

    MATLAB creates a subfolder with the same name as the .ZIP file and extracts the files from that .ZIP file into the newly created folder.

  5. In the Current Folder browser, expand the newly created folder, and then double-click the settings file you want to use.

    A keyboard key icon preceding a file name indicates a valid keyboard shortcut settings file.

  6. In the Keyboard Shortcuts Preferences dialog box, review the settings, and then click OK.

The newly downloaded settings file is now in effect.

Compare Sets of Keyboard Shortcuts

Compare sets of keyboard shortcuts to:

  • Upgrade MATLAB from a version before Version 7.9 (R2009b).

    MATLAB 7.9 made keyboard shortcuts consistent across the desktop. Therefore, you might find that shortcuts you used before Version 7.9 are different.

  • See how a set of keyboard shortcuts you found on File Exchange differs from your current set of keyboard shortcuts.

  • See how a set of keyboard shortcuts differs from the default set.

Steps for Comparing Keyboard Shortcuts

To compare your current set of keyboard shortcuts to another set:

  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard > Shortcuts.

  2. Click the Actions button .

  3. From the drop-down menu, choose the set of keyboard shortcuts to which you want to compare the current set.

  4. The Comparison Tool opens and displays the two keyboard shortcut sets side-by-side.

Read the Results of Comparing Sets of Keyboard Shortcuts

When you compare keyboard shortcut sets, they appear in the Comparison Tool as follows:

  • One set displays on the left side of the tool and the other set displays on the right side of the tool.

  • Each column header displays the name of the keyboard shortcut set contained within the column.

  • Highlighting identifies rows that differ:

    • Rows that exist in one file, but not the other, appear in green highlighting.

    • Rows that appear in both files, but that differ in content appear in pink highlighting.

  • When multiple desktop tools support the same keyboard shortcut for a single desktop action, there is a row for each tool. For example, if both the MATLAB desktop and the Editor support the keyboard shortcut Ctrl+W for closing a selected window, a column of the Comparison Tool might appear like this:

  • When there are multiple keyboard shortcuts for the same action in a single tool, there is a row for each keyboard shortcut. For example, if there are two different keyboard shortcuts in the Editor for applying a code analyzer autofix, a column of the Comparison Tool might appear like this:

  • On Macintosh platforms, the textual format of keyboard shortcuts is slightly different from other platforms, and also differs from the representation shown on MATLAB desktop menus. These differences are due to the Macintosh platform displaying shortcuts using symbols. For instance, the Macintosh platform uses the symbol for a keyboard key. Because the Comparison Tool represents symbols as text strings; it specifies the symbol as CMD.

See also Using Comparison Tool Features.

Display Keyboard Shortcuts

The following sections describe the various ways you can display keyboard shortcuts:

List All Keyboard Shortcuts in a Set

You can copy all the keyboard shortcuts from a keyboard shortcuts set and paste them in a text file or spreadsheet application, such as Microsoft® Excel®. To create a list of keyboard shortcuts for easy browsing and future reference, follow these steps:

  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard > Shortcuts.

  2. Click the Actions button .

  3. From the drop-down menu, choose Copy to Clipboard.

  4. Open a spreadsheet application or a text editor.

    For the best formatting use a spreadsheet application.

  5. Paste in the data from the clipboard.

    In Microsoft Excel, for example, choose Home > Paste.

Display Keyboard Shortcuts on Menus

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 Customize Keyboard Shortcuts.

Display Keyboard Shortcuts in the Preferences Dialog Box

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

  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > 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 adding a string describing the action. For example, add 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. Select the action name of interest. In this example, select Clear Selection.

  5. View the table labeled Shortcuts for Clear Selection. It indicates that the Escape key is the current keyboard shortcut for the Clear Selection action in the Editor.

Customize Keyboard Shortcuts

You can customize or view keyboard shortcuts for MATLAB desktop tools. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard > Shortcuts. If you have an active Internet connection, you can watch the Customizable Keyboard Shortcuts videoCustomizable Keyboard Shortcuts video for an overview.

The following sections provide details:

Steps for Customizing Keyboard Shortcuts

  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > 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 Choose 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 Filter 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 Specify 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 any conflicts, indicated by the informational and error icons.

    For more information, see Evaluate and Resolve Keyboard Shortcut Conflicts.

  8. Click Apply.

    • The keyboard shortcut becomes available immediately.

    • If a changed shortcut corresponds to a menu option that previously displayed no keyboard shortcut, MATLAB reflects the new keyboard shortcut on the menu.

Restore Default Keyboard Shortcut Sets

If you modify keyboard shortcuts, and then decide you do not want to keep the changes, you can restore the default shortcuts. To restore the default state of a keyboard shortcut:

  1. Click the Actions button .

  2. Select Undo Modifications to Windows Default Set (modified) or Undo Modifications to Emacs Default Set (modified), as appropriate for your system.

  3. Click OK.

    Note:   Undoing modifications reverts all keyboard shortcuts changes that you made to the set. You cannot undo modifications on a shortcut-by-shortcut basis.

Save Keyboard Shortcuts to a Settings File

Save keyboard shortcuts to a settings file to:

  • Save changes you make to a default settings file, such as the Windows default set, to a new set.

    MATLAB preserves changes you make to the default sets across sessions. However, if you undo modifications to a default keyboard shortcut set (as described in Restore Default Keyboard Shortcut Sets) you lose all changes, unless you first save them to a new set.

  • Copy the keyboard shortcuts settings file to another system running MATLAB and use it there.

  • Overwrite a settings file that you previously saved.

    You cannot overwrite the default settings files that install with MATLAB. MATLAB saves modifications that you make to a default set using the name of the default set appended with the text (modified). For instance, Windows default (modified).

  • Share a keyboard shortcuts settings file with others.

    For example, you can submit your file to the File Exchange repository. Click this link to go directly to the page where you can submit your file: MATLAB Central File Exchange — Submit New File.

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

  1. Open the Keyboard Shortcuts Preferences dialog box. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard > Shortcuts.

  2. Click the Actions button , and then select Save As.

  3. In the Save dialog box, navigate to the folder where 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 you specified.

Filter Keyboard Shortcut Actions

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

  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 a list of the action names associated with the tool or menu you specify. In addition, the list 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 keystrokes or typing the key names.

        For example, to enter Ctrl+S, use the keystroke (by pressing the Ctrl key and the S key). Or, type Ctrl+S character by character (C-t-r-l-+-Y).

      • If using keystrokes for a keyboard shortcut does not work, try typing the characters instead. You must type some keyboard shortcuts character by character, such as shortcuts including the Tab, Backspace, or Delete keys.

      • Type numpad to refer to the number pad that is on the far right of some keyboards.

      • Type Up or Down to refer to the Up arrow or Down arrow keypad keys, respectively.

  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.

Specify Keystrokes for a Keyboard Shortcut

A keystroke can be a single key or the combination of a modifier (Alt, Shift, or Ctrl) and another key. When you create a keyboard shortcut, specify the keystrokes for the 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 number of keystrokes, 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 by typing the key names character by character.

      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 already have a defined action within dialog boxes. For example, the Tab key navigates from one field to the next in dialog boxes.

Evaluate and Resolve Keyboard Shortcut Conflicts

Conflicts arise when two or more different actions have the same shortcut. 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 — On the Home tab, in the Environment section, click Preferences. Select MATLAB > 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:

  • You use both tools frequently.

  • You perform both actions frequently.

  • You have difficulty remembering the action that the shortcut performs in each tool.

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:

  • The situation is temporary.

    For instance, you are performing a two-step procedure. In the first step, you assign the keyboard shortcut to an action that results in a conflict. Then, in the second step, you remove the shortcut from the original action.

  • The two actions are associated with different modes of the same tool.

    By default, when the MATLAB Editor is in cell mode, Ctrl+Up and Ctrl+Down move the cursor to the Next and Previous cell, respectively. When the Editor is not in cell mode, those keyboard shortcuts scroll up and scroll down, respectively. The shortcuts are in conflict, but the behavior probably is expected, for the given MATLAB Editor mode.

    Although not evident from the preferences pane, Ctrl+C presents a similar situation on Windows systems. Ctrl+C is the keyboard shortcut for interrupting MATLAB execution. However, the default keyboard shortcut for the copy action is also Ctrl+C. Therefore, if you:

    • Select an item, and then press Ctrl+C, it copies the selected item to the clipboard, — regardless of whether MATLAB is busy.

    • Do not select an item and press Ctrl+C, it interrupts MATLAB execution.

    If you change the default keyboard shortcut for the copy action from Ctrl+C to another keystroke, then Ctrl+C interrupts MATLAB execution, regardless of whether you have selected an item.

Resolve 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. On the Home tab, in the Environment section, click Preferences. Select MATLAB > 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:

  • The Add to Favorites dialog box opens when you press Ctrl+S, Alt+V in the Help browser.

  • Ctrl+S, Alt+V appears next to Add to Favorites when you click the Favorites menu in the Help browser.

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. On the Home tab, in the Environment section, click Preferences > Keyboard > Shortcuts.

  2. Under Active settings, choose Windows Default Set.

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

  4. Under Action name, select Decrease Indent.

  5. In the table labeled Shortcuts for Decrease Indent, under Shortcut, click Ctrl+[. MATLAB makes the field editable.

  6. In the Shortcut field, press Ctrl+Backspace twice.

    The first time you press the key combination, it deletes Ctrl+[. The second time you press it, Ctrl+Backspace appears in the field.

  7. 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, on Windows, you press Alt+Enter (to apply a code analyzer autofix) instead of Ctrl+Enter (to evaluate the current cell in the MATLAB Editor ). To avoid accidentally applying an autofix, delete the Alt+Enter shortcut by following these steps:

  1. On the Home tab, in the Environment section, click Preferences. Select 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 Message.

  5. In the next table, under Shortcuts for Autofix Message, 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.

See also Delete a Set of Keyboard Shortcuts.

Delete a Set of Keyboard Shortcuts

If you previously saved or copied a set of keyboard shortcuts to your system and you no longer want it, delete it as follows:

  1. On the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard > Shortcuts.

  2. Under Active settings, choose the set of keyboard shortcuts that you want to delete.

    You cannot delete default keyboard shortcut sets, such as Windows Default Set.

  3. Click the Actions button and choose Delete filename, where filename is the name of a keyboard shortcut set you previously saved or copied to your system.

For information on deleting a single keyboard shortcut from a set that you want to keep, see Deleting a Keyboard Shortcut.

Use 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 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. On the Home tab, in the Environment section, click Preferences. Select MATLAB > 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.

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:

  • Figure windows—For example, you cannot modify the keyboard shortcut, Ctrl+S, for saving a MATLAB .fig file.

  • Toolboxes—For example, you cannot modify keyboard shortcuts in the SimBiology® desktop.

  • Incremental search—You can modify the keyboard shortcuts for initiating a forward or backward incremental search. However, you cannot change the keyboard shortcuts that you use within incremental search mode, such as Ctrl+Shift+S to search forward.

  • Dialog boxes—For example, you cannot create a keyboard shortcut for the OK button.

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

  • Command Window: Ctrl+0

  • Command History: Ctrl+1

  • Current Folder: Ctrl+2

  • Workspace: Ctrl+3

  • Profiler: Ctrl+4

  • Figure Palette: Ctrl+6

  • Plot Browser: Ctrl+7

  • Property Editor: Ctrl+8

  • Editor: Ctrl+Shift+0

  • Figures: Ctrl+Shift+1

  • Web browser: Ctrl+Shift+2

  • Variables Editor: Ctrl+Shift+3

  • Comparison Tool: Ctrl+Shift+4

  • Help browser: Ctrl+Shift+5

Was this topic helpful?