27.3 Accelerator keys

An accelerator key is different from a menu shortcut key. To use a View menu shortcut, you press Alt+V to open the View menu, and then press P or C to change the cursor. But an accelerator key is a single key or key combination that takes effect without opening any menu.

Adding an accelerator key for an existing menu item is easy. You go to the Resource View in the Visual Studio Workspace window, click on Accelerators, double-click on IDR_MAINFRAME to see the list of accelerator keys. Down at the bottom is a blank box with a dotted line around it. Double-click it or press Alt+Enter to open the accelerator key Properties dialog.

In the ID field you put the menu item selection that you want imitate. If you don't remember the name of the selection, pressing the Arrow key next to the ID field will show a list with all the existing selection IDs. In the Letter field you put the key that you want to use for the accelerator. There are three fields that you can turn on or off, according to whether you want to require a Ctrl, Alt, or Shift key with your key press.

It's often a convention to put the name of a menu item's accelerator key on the right side of the menu after the selection name. One thing to note about accelerator keys is that they don't work while a menu is open; unless of course the menu item shortcut happens to be the same key as the accelerator key.

    Part I: Software Engineering and Computer Games
    Part II: Software Engineering and Computer Games Reference