To print: Click here or Select File and then Print from your browser's menu
Applying Customization: Using Accelerator Keys
by: Dave Pitzer
URL: http://pointa.autodesk.com/gotoPointA.jsp?dest=3_3pitzcust

In this installment, we are going to return to menu customization and take a look at accelerator keys. An accelerator key is a combination of certain keystrokes that, when pressed together, perform a function. For example, every time you press the Ctrl key and the S key simultaneously (Ctrl+S) to execute the SAVE command, you are using an accelerator-key combination.

Pre-defined Accelerator Keys
AutoCAD® software comes with some 19 accelerator-key combinations already defined in the ***ACCELERATOR section of the acad.mnu, as shown below.


(click to enlarge)

Note: In the examples above, the +TOOLBAR modifier specifies the menu section for AutoCAD to search. It can be ignored for our purposes. Prior to AutoCAD 2000i, the +TOOLBAR feature is absent.

Several of these accelerator-key combinations conform to Windows application standards—such as Ctrl+O for OPEN, Ctrl+S for SAVE, Ctrl+Z for UNDO, and so on.

Accelerator Key Formats
To see how accelerators work and the two forms they can take, consider the short sample ***ACCELERATORS section below:

The ***ACCELERATORS section can contain items in one of two formats. The first is a nametag (such as ID_Line, above) followed by a label containing modifiers. The modifiers are followed by either a single character or a special virtual key string (such as "F12") enclosed in quotation marks. This format maps a key sequence to a menu item. In the example above—item 1—the keyboard combination of SHIFT+CONTROL+L will reference the menu macro with the nametag ID_Line elsewhere in the menu. You can concatenate more than one modifier with another by using the plus symbol (+), as in the first example above. When a special key sequence is recognized, the menu item associated with the nametag is executed as if you had chosen the menu item.

The second format for defining an accelerator—items 2 and 3 above—uses a label containing a modifier and key string followed by a command sequence (menu macro). This method maps a key sequence to a command string and does not have a corresponding menu item. Item 3 above, for example, uses the Ctrl, the Shift, and the Z key to execute the ZOOM command with the Extents option. The formatting and special characters used in the menu macro are the same as those used in other menu items, except that the backslash character (\) cannot be used as the PAUSE command. If you want to use the backslash character, use the item 1 format for defining an accelerator to map a modifier and key string to a menu item that performs the command sequence that includes the desired pause.

Valid Accelerator Key Modifiers
The following table lists the valid modifiers.

Valid Modifiers
String
Description
CONTROL Ctrl key
SHIFT Shift key, either right or left

The following table lists the special virtual keys. (These keys must be enclosed in quotation marks.)

Special Virtual Keys
String
Description
Exceptions
F1
F1 key
Assigning a menu macro to the F1 key is discouraged because this key is generally associated with Help. Using a modifier with this key is acceptable.
F2
F2 key
Unmodified, this toggle key switches the state of the text window.
F3
F3 key
Unmodified, this key runs OSNAP.
F4
F4 key
Unmodified, this toggle key switches TABMODE on or off.
F5
F5 key
Unmodified, this toggle key switches ISOPLANE on or off.
F6
F6 key
Unmodified, this toggle key switches COORDS on or off.
F7
F7 key
Unmodified, this toggle key switches GRIDMODE on or off.
F8
F8 key
Unmodified, this toggle key switches ORTHOMODE on or off.
F9
F9 key
Unmodified, this toggle key switches SNAPMODE on or off.
F10
F10 key
Unmodified, this toggle key switches Polar Tracking on or off.
F11
F11 key
Unmodified, this toggle key switches Object Snap Tracking on or off.
F12
F12 key
None
INSERT
Ins key
Must be used with the CONTROL modifier.
DELETE
Del key
Must be used with the CONTROL modifier.
ESCAPE
Esc key
Assigning a menu macro to the Esc key is discouraged because this key is generally associated with Cancel. You cannot assign a menu macro to Ctrl+Esc and Ctrl+Shift+Esc; Windows controls these sequences. Using the SHIFT modifier with the Esc key is acceptable.
UP
Up Arrow key
Must be used with the CONTROL modifier.
DOWN
Down Arrow key
Must be used with the CONTROL modifier.
LEFT
Left Arrow key
Must be used with the CONTROL modifier.
RIGHT
Right Arrow key
Must be used with the CONTROL modifier.
NUMPAD0
0 key
None
NUMPAD1
1 key
None
NUMPAD2
2 key
None
NUMPAD3
3 key
None
NUMPAD4
4 key
None
NUMPAD5
5 key
None
NUMPAD6
6 key
None
NUMPAD7
7 key
None
NUMPAD8
8 key
None
NUMPAD9
9 key
None

A Simple Example
Now let's assume that you want to assign an accelerator-key combination that will issue the VLIDE command to open and display the Visual LISP™ IDE facility. Here is one possible definition that you could add to your ***ACCELERATORS menu section:

ID_AULPIDE [CONTROL+"6"]

The nametag ID_AULPIDE is used in the Tools drop-down (POP6) menu where it appears as follows:

ID_AULPIDE [&Visual LISP Editor]^C^C_vlide

Keyboard accelerators are handy ways to execute frequently used commands and provide yet another way for you to customize your AutoCAD installation to meet you needs and improve your efficiency.

Next time, we'll look at still other methods of customization.



Dave Pitzer has been using AutoCAD since 1986 and teaching AutoCAD and AutoLISP at the college level since 1995. He is also co-author of Inside AutoCAD 2002, Inside AutoCAD Release 13, and Inside AutoCAD Release 14 from New Riders Publishing, a Contributing Editor to CADALYST Magazine, and a member of the Adjunct Faculty at Santa Rosa Junior College in Santa Rosa, California.