Next: , Previous: Adding tool bar buttons, Up: Customizing through XML files


16.4.7 Binding actions to keys

All the actions defined above can be bound to specific key shortcuts through the <key> attribute. As usual, it requires one <action> attribute to specify what to do when the key is pressed. The name of the action can start with a '/' to indicate that a menu should be executed instead of a user-defined action.

This tag doesn't contain any child tag. Instead, its text contents specified the keyboard shortcut. The name of the key can be prefixed by control-, alt-, shift- or any combination of these to specify the key modifiers to apply.

You can also define multiple key bindings similar to Emacs's by separating them by a space. For instance, control-x control-k means that the user should press <control-x>, followed by a <control-k> to activate the corresponding action.

Use an empty string to describe the key binding if you wish to deactivate a preexisting binding. The second example below deactivates the standard binding.

     <?xml version="1.0" ?>
     <keys>
       <key action="expand alias">control-o</key>
       <key action="Jump to matching delimiter" />
     
       <!--  Bind a key to a menu -->
       <key action="/Window/Close">control-x control-w</key>
     </key>

Multiple actions can be bound to the same key binding. They will all be executed in turn, followed by any menu for which this key is an accelerator.

When GPS processes a <key> tag, it does the following: