Home Page (Objects) | Overview | FAQ | Reference
Applies to: Application object
Binds one or more keystrokes to a command.
Syntax
object.AddKeyBinding key, command, editor
Parameters
object
An expression that evaluates to an Application object. When you use the AddKeyBinding method of the Application object, you can omit object because the name of the Application object is implied when you access its properties and methods.
key
A String specifying the keystrokes needed to execute command. This string has the format CTRL+ALT+SHIFT+A, where CTRL, ALT, and SHIFT always appear in this order. If a two-key sequence represents a command, the two keys are separated by a comma, as in CTRL+HOME, S or X, SHIFT+Y.
command
A String specifying the command that key executes.
editor
A String specifying the editor associated with this keybinding. These editors appear on the Keyboard tab of the Customize dialog box (Tools menu, Customize command).
Remarks
If the user removes (uninstalls) an add-in, Developer Studio does not remove keybindings created when the add-in was installed, because the user might have customized these keybindings
Caution Unless keybindings are necessary, do not add them, because they might conflict with existing keybindings — producing unpredictable results for the user.
Example
The following Visual C++ code binds a keystroke to an add-in command:
if (bFirstTime == VARIANT_TRUE)
{
CComBSTR bszKeystroke("CTRL+4");
CComBSTR bszEditor("Main");
VERIFY(SUCCEEDED(pApplication->
AddKeyBinding(bszKeystroke, bszCmdName, bszEditor)));
}
See Also AddCommand method, Adding Commands to Developer Studio, AddCommandBarButton method, EnableModeless method, SetAddInInfo method.