Binding Add-In Commands to Keys
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Binding Add-In Commands to Keys 

In Visual Studio, you can associate (or "bind") one or more keyboard shortcuts to a command by selecting Options from the Tools menu and choosing the Keyboard page from the Environment folder. For example, rather than clicking the File menu, pointing to the Project command, and clicking the New command to create a new project, you can instead simply press the keyboard shortcut, CTRL+SHIFT+N. You can create or change keyboard shortcuts for any command in Visual Studio, including Visual Studio commands, macro commands, and add-in commands. For more information, see Shortcut Keys.

In some cases, you might want to do this programmatically in your add-in rather than force your users to manually bind the keys themselves through the Options dialog box. You can do this by using the Bindings property of the Command object.

In This Section

Bindings Property Parameter Format

Outlines the parameters used by the Bindings property and how they affect key binding.

How to: View Existing Key Bindings

Provides code that enables you to view the existing key bindings.

How to: Bind a Command to a Single Shortcut Key

Demonstrates how to bind a command to a single shortcut key.

How to: Bind a Command To Multiple Combinations of Shortcut Keys

Demonstrates how to bind a command to a multi-key shortcut.

How to: Preserve Existing Command Key Bindings

Demonstrates how to add new key bindings while preserving existing ones.

Related Sections

Displaying Add-Ins on Toolbars and Menus

Explains how to display add-in commands on Visual Studio toolbars and menus.

Shortcut Keys

Explains how to create shortcut keys in Visual Studio.

© 2016 Microsoft