DreamweaverFAQ.com
Search the site!Search DWfaq.com | Print This PagePrinter Friendly Page
Current: Default | Default: Midnight Madness


DreamweaverFAQ.com » Tutorials » Extensions » Custom Commands- Keyboard Shortcuts


Q. How do you add keyboard shortcuts to custom Commands?

A. Find an available Dreamweaver keyboard shortcut combination and add it to the menus.xml file.

Custom Commands- Keyboard Shortcuts

Introduction

When you add or record a frequently used Command in Dreamweaver it's handy to have a keyboard shortcut to activate it. We'll walk through the steps to do this using a Command I recorded for my version of Dreamweaver that inserts a "Null Link". First we will find an available Dreamweaver keyboard shortcut combination and then edit the menus.xml file.

Note: For more information about recording Commands read over Dreamweaver 4 Help topics, "Creating new commands from history steps" and "Modifying the Commands menu".

The menus.xml file can be a bit overwhelming at first look. For a better understanding of how menus.xml is structured read over Dreamweaver 4 Help topic, "About menus.xml tag syntax".

Here is an example of part of my menus.xml file.

<separator /> 
<menuitem name="_Format Table..." file="Commands/Format Table.htm" id="DWMenu_Commands_FormatTable" />
<menuitem name="_Sort Table..." file="Commands/Sort Table.htm" id="DWMenu_Commands_SortTable" />
<menuitem name="Null Link" key="Cmd+Alt+N" file="Commands/Null Link.htm" id="DWMenu_Commands_Null_Link" />
<menuitem name="Nirvana_Floating_Layer" file="Commands/Nirvana_Floating_Layer.htm" id="float" />
<menuitem name="Floating_Screen_Position_Layer" file="Commands/Floatingbyscreenres.htm" id="floatscreen" />

Finding keyboard shortcuts

The first thing we have to do is find an available keyboard shortcut. To do this we'll need to have a look at Dreamweaver's "Keyboard Shortcut Matrix". Open Dreamweaver Help: Help» Using Dreamweaver. Look at the Category Keyboard Shortcuts» Keyboard Shortcut Matrix.

In the "Keyboard Shortcut Matrix" we'll look for an available keyboard shortcut combination that includes the letter "N" to represent our "Null Link" command. Have a look in the "Keyboard character" column for the letter "N". To the right of "N" in column four is an asterisk (*), which indicates an unused key combination. At the top of column four we'll see, Control+Alt (Windows) or Command+Option (Macintosh).

We now have an available keyboard shortcut for our Command, Control+Alt+N (Windows) or Command+Option+N (Macintosh).

Editing Menus.xml

The new keyboard shortcut needs to be attached to the "Null Link" Command (Dreamweaver\Configuration\Commands\Null Link.htm) and made to show up in Dreamweaver's Commands menu.

Important: The steps below involve editing and adding to menus.xml. If you make a mistake you could easily corrupt all the menus in Dreamweaver. Before you begin make a backup copy of the menus.xml file. Don't open menus.xml in Dreamweaver; use BBEdit, HomeSite or a plain text editor.

  1. Open menus.xml in BBEdit, HomeSite or your favorite plain text editor.
    Dreamweaver\Configuration\Menus\menus.xml

  2. Using your editors find function, search menus.xml for "_Commands". When you look under the "_Commands" menu you would notice that neither "Null Link" nor "Null Link.htm" are listed with the other menu item names. This is because Dreamweaver automatically recognizes and adds recorded Commands to the Commands menu without adding them to the menus.xml file.

  3. To attach a keyboard shortcut to "Null Link.htm" we'll need to create a new menu item for the "Null Link" command. Within the "_Commands" menu immediately following the "_Sort Table" menu item we'll insert the following code.

    <menuitem name="Null Link" key="Cmd+Alt+N" 
    	file="Commands/Null Link.htm" id="DWMenu_Commands_Null_Link" /> 
  4. We have defined a new menu item, added our keyboard shortcut combination, added the path to the "Null Link.htm" file and gave the new menu item a unique ID. Save and close menus.xml.

Next time you open Dreamweaver your new Command will be listed in the Commands menu along with your keyboard shortcut. If your using Windows you'll notice the keyboard shortcut in the Commands menu has magically change to Ctrl+Alt+N and on the Macintosh to the appropriate keyboard shortcut symbols.

Cheers, you're done!

::This page last modified 8/13/2013 at 04:37::

Copyright © 2001-2024 DreamweaverFAQ.com All Rights Reserved.
All brands, trademarks, tutorials, extensions, code, and articles are the property of their respective owners.
A production of Site Drive Inc.
Legal Notice | Privacy Policy | Disclaimer & Notice