8.10. The "Add Keyboard Shortcut" dialog box
Prev | 8. Dialog boxes | Next

### 8.10. The "Add Keyboard Shortcut" dialog box

This dialog box is displayed by menu item Options → Customize Configuration → Add Keyboard Shortcut. It allows the user to specify a keyboard shortcut that will invoke a predefined command, last recorded macro-command or a user-defined macro-command.

In the above screen shot, the user adds a shortcut for command "`insertCharSequence`" with parameter "`- mdash`". This command will be invoked after character "`-`" (dash) is typed.

Procedure 2. Adding a keyboard shortcut

1. Specify a keystroke. A keystroke is either:

   - A typed character specified the Typed Character field.

     A typed character is any character you can type using any combination/sequence of pressed keys. A typed character often does not correspond to a key of your keyboard. For example, on an US keyboard, there is no $ key. You need to press on key 4 and on key Shift at the same time in order to type the '`$`' character.

   - OR a pressed key specified using the Pressed Key combo box.

     A pressed key must correspond to a key actually found on your keyboard. For example, do not choose key $ on an US keyboard because there is no such key. On the other hand, you may choose it on a French keyboard which has a $ key[15].

     You'll often want to also specify the modifier keys (Ctrl, Shift, etc) which must be pressed at the same time as the main key specified in the Pressed Key combo box. Any combination of modifier keys may be chosen using the Pressed Key Modifiers combo box.

2. Optionally specify a second keystroke. In such case, the command will be invoked by the sequence: first keystroke immediately followed by second keystroke.

3. Specify the command invoked by your custom shortcut. There are three possible options for this:

   Command

     The command invoked by your custom keyboard shortcut is a predefined command (documented in Chapter 6, Commands written in the Java™ programming language in <ttl>XMLmind XML Editor - Commands</ttl>).

     You may choose one of the last executed commands by using the list displayed by the "Choose from last executed command" button.

   Last recorded macro

     The command invoked by your custom keyboard shortcut is the last recorded macro-command (see Tools → Record Macro).

   Other macro-command

     The command invoked by your custom keyboard shortcut is a custom macro-command that you'll type in the text area below the "Other macro-command" radio button.

   It is recommended to restrict yourself to specifying one of the last executed commands or last recorded macro. Attempting to use the other options is harmless, but unless you know what you are doing (for example, because you have posted a support request to the `<xmleditor-support@xmlmind.com>` public mailing list), the commands specified the hard way will probably not work.

   However, if you decide to follow the hard way, you must know that:

   - The Command field, allowing to specify the name of a command, supports auto-completion.

   - Clicking on the Documentation link will open in the Web browser the reference manual in <ttl>XMLmind XML Editor - Commands</ttl> describing the command of interest[16]. This is almost always needed in order to specify in the Parameter field a valid parameter for the command.

   - If you type a custom macro-command in the text area, do not bother declaring namespace prefixes. Consider that "`http://www.xmlmind.com/xmleditor/schema/configuration`" is declared as being the default namespace, that "`cfg`" is declared as a prefix for namespace "`http://www.xmlmind.com/xmleditor/schema/configuration`" and that all namespace prefixes declared in the document being edited (see Tools → Declare Namespace) are in scope also here.

4. Click OK.

Other example:

In the above screen shot, the user adds a shortcut for command "`insert after[implicitElement] #template(figure,screenshot)`". This command will be invoked when the Insert key will be pressed at the same time as the Control and Shift keys.

Previously, by using the Edit tool, the user has inserted in the document being edited a `figure` element containing a `screenshot` child element[17]. Having done this now allows her/him to pick this command from the list displayed by the "Choose from last executed command" button, instead of typing the command name and its parameter.

### Note

Many keystrokes may not be used to define custom keyboard shortcuts. Clicking on the "Existing Keyboard Shortcuts" tab will give you an idea of this fact.

Examples:

- You may not use Ctrl+O because this keystroke is reserved for menu item File → Open.

- You may not use Ctrl+I because this keystroke is reserved for menu item Edit → Insert.

- You cannot use single keystroke Esc because this would prevent existing keyboard shortcuts Esc g (bound to menu item Select → Find Element), Esc x (bound to menu item Tools → Execute) , etc, from working[18].

- You cannot use keystroke Home, for example followed by a second Home keystroke, because existing keyboard shortcut Home (bound to command "`moveDotTo lineBegin`") would prevent your custom shortcut from working.

Moreover certain keystrokes are reserved by Java™ (e.g. Tab, Alt) or by the operating system (e.g. there are loads of these on the Mac). Attempting to use these keystrokes for your custom keyboard shortcuts will almost certainly not work.

#### 8.10.1. Removing a previously defined keyboard shortcut

This dialog box also allows to remove user-defined keyboard shortcuts.

In the above screen shot, notice how removing user-defined keyboard shortcut Ctrl+Shift+Insert (invoking command "`insert after[implicitElement] #template(figure,screenshot)`") would restore the predefined keyboard shortcut (invoking command "`insertNode sameElementBefore[implicitElement]`").

Procedure 3. Removing a keyboard shortcut

1. Click on the "Existing Keyboard Shortcuts" tab.

2. Select the keyboard shortcut to be removed by clicking on it.

   You can only remove the keyboard shortcuts you have created. You cannot remove predefined (grayed) keyboard shortcuts.

3. Click on the Remove button.

   Note that this operation takes immediate effect: clicking on the Cancel button of the "Add Keyboard Shortcut" dialog box will not cancel the deletion of the keyboard shortcut[19].

[15] Suprising, isn't it?

[16] This requires an access to the Internet if XMLmind XML Editor is deployed using Java™ Web Start.

[17] She/he picked `figure(screenshot)` from the list of elements suggested by the Edit tool.

[18] Using Esc followed by a second, carefully chosen, keystroke should work fine.

[19] The Cancel button of the "Add Keyboard Shortcut" dialog box just cancels the action of creating a new keyboard shortcut.

Prev | Up | Next
8.9. The "Save Selected Element as Template" dialog box | Home | 8.11. The "Change Document Conversion Parameters" dialog box