### Key configurations

Key configurations are used to represent a general style or theme of key bindings. For example, the Workbench provides a "Standard" key configuration and an "Emacs" key configuration. Only one key configuration is active at any given time. End users control which one is active using the workbench Preferences dialog.

From an implementation point of view, key configurations are simply named groupings of key bindings. A key configuration won't accomplish anything on its own unless there are key bindings associated with it.

Let's look again at the workbench markup for org.eclipse.ui.commands to find the key binding definitions and how a key configuration gets associated with a key binding.

    ...
    <keyBinding
           string="Ctrl+S"
           command="org.eclipse.ui.file.save"
           configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
    </keyBinding>
    ...
    <keyBinding
           string="Ctrl+X Ctrl+S"
           command="org.eclipse.ui.file.save"
           configuration="org.eclipse.ui.emacsAcceleratorConfiguration">
    </keyBinding>
    ...

There are two different key bindings defined for the "org.eclipse.ui.file.save" command. Note that each one has a different configuration defined. When the standard configuration is active, the "Ctrl+S" key binding will invoke the command. When the emacs configuration is active, the sequence "Ctrl+X Ctrl+S" will invoke the command.

#### Defining new key configurations

When your plug-in defines a key binding, it will most likely assign it to an existing key configuration. However, your plug-in may want to define a completely new style of key configurations. If this is the case, you can define a new type of key configuration inside the org.eclipse.ui.commands definition. The workbench markup that defines the standard and emacs key configurations are shown below:

    ...
    <keyConfiguration
           name="%keyConfiguration.standard.name"
           description="%keyConfiguration.standard.description"
           id="org.eclipse.ui.defaultAcceleratorConfiguration">
    </keyConfiguration>
    <keyConfiguration
           name="%keyConfiguration.emacs.name"
           parent="org.eclipse.ui.defaultAcceleratorConfiguration"
           description="%keyConfiguration.emacs.description"
           id="org.eclipse.ui.emacsAcceleratorConfiguration">
    </keyConfiguration>
    ...

Note that the name defined here is the one used in the preferences page in the list of configurations.

#### Activating a key configuration

The user controls the active configuration via the preferences page. However, you can define the default active configuration as part of the org.eclipse.ui.commands definition. The workbench establishes the standard key configuration as the default when it defines the extension:

    <extension
             point="org.eclipse.ui.commands">
          <activeKeyConfiguration
                value="org.eclipse.ui.defaultAcceleratorConfiguration">
          </activeKeyConfiguration>
          ...