Documentation/How Tos/Edit Keyboard Configuration File

From Apache OpenOffice Wiki
< Documentation‎ | How Tos
Revision as of 13:55, 30 June 2018 by Sancho (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Edit-find-replace.png This article should be checked for accuracy and conformity to style.

Documentation windows.png Windows related content Version 2.0 to 3.0.1

Up to OOo3.0 it is not possible to define a shortcut key which includes the ALT-key using the Customize dialog, Issue 4756 . But you must edit the configuration file to get such a shortcut. This is a description, how to do it. Most of the sections below have only been tested with WinXP. Some information specifically for the Linux version can be found at the end of the page.

You need an editor, which preserves Unix line ends and the coding "UTF-8", and which will not set a byte order mark. I have used "PSPAD" or "jEdit" on WinXP. On WinXP neither WordPad nor NotePad is suitable. OOo itself can export in UTF-8 and Unix line ends, but sets a byte order mark, so you cannot use OOo.

On WinXP the keybord settings for the single modules are in the files

<..>\user\config\soffice.cfg\modules\<module name>\accelerator\<language code>\current.xml

and general keyboard settings are in the file

<..>\user\config\soffice.cfg\global\accelerator\<language code>\current.xml

Older versions of OOo might not have these files by default. If they are missing, go to Tool | Customize | Keyboard and change something. Then the files will be generated.

  1. Close OOo and close quickstarter.
  2. Make a copy of the file, you will work on.
  3. Open the file in an editor.
  4. Edit the file and save it.
  5. Start OOo.

If something is wrong, OOo will crash when you press a key. Do not try to restore the document and do not sent a crash report. But restore the original file with the copy you have made in step 2.

To learn more about this file, see "StarOffice 7 Administration Guide" chapter 4 [1], "StarOffice 8 Administration Guide" chapter 3 and appendix A [2], and " XML File Format 1.0 Technical Reference Manual", chapter 9.2 [3].

Let us have a deeper look at the file. You will see something like

<?xml version="1.0" encoding="UTF-8"?>
<accel:acceleratorlist xmlns:accel="" xmlns:xlink="">
	<accel:item accel:code="KEY_Q" accel:mod1="true" xlink:href=".uno:Quit"/>
	<accel:item accel:code="KEY_N" accel:shift="true" accel:mod1="true" xlink:href=".uno:NewDoc"/>

You will notice that the lines have all the same structure.

Each such line defines a single shortcut key.

You can use only keys which has got a name. I don't know where to find a actual list of all possible keys and which of them will work, dependent on keyboard, operating system and language. If you know something, please add the information.

Next the modifier keys are listed. You need only those, which are used, because the default value of the modifier keys is "false".

That is the CRTL-key.
That is the ALT-key.
That is the SHIFT-key.

Instead of pressing the keys CRTL and ALT together, you can also press the key AltGr That's on a German keyboard. Would be nice, if someone corrects this for an English keyboard.

The last position describes what the shortcut should do, for example

will close OOo.

Inside the quotes stands a Command URL. In older OOo versions the command URL could be build as
but that way should not be used for newer versions, if a ".uno" form exists. Therefore always use

You find those commands in the document [4] in the first column or in the above mentioned document "StarOffice 8 Administration Guide".

Some of the commands need parameters. There seems to be no list of those parameters, but you can get a hint, if you record a macro and look, which parameters the dispatcher gets. For example the macro record of inserting a special character gives you the Command URL ".uno:InsertSymbol" and the parameter "Symbols" with for example the value "δ" (Greek delta). Or look at the existing lines in the configuration files. Perhaps you can alter a parameter?

Such parameters follow the command after a ?. For inserting the character "δ" the complete Command URL is ".uno:InsertSymbol?Symbols:string=δ".

The first part after the character ? is the name of the parameter. It is followed be the character :. After this colon the type of the parameter value is given and then after the character = the value itself.

For example, inserting unformatted text is the command ".uno:ClipboardFormatItems?SelectedFormat:short=1".

Modifier keys and command URL may be exchanged.

The complete line for inserting the special character δ when pressing the keys AltGr (German) and D together is then

<accel:item accel:code="KEY_D" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertSymbol?Symbols:string=δ" /> Version 3.1

From OOo version 3.1 an xcu format is used for the keyboard configuration file. This format is common for other configurations too. The corresponding schema is defined in
...\ 3\Basis\share\registry\schema\org\openoffice\Office\Accelerators.xcs
The default keyboard shortcuts, which are valid for all users, are defined in the file
...\ 3\Basis\share\registry\data\org\openoffice\Office\Accelerators.xcu

If you use another local than en-US, for example de, then the file

...\ 3\Basis\share\registry\res\de\org\openoffice\Office\Accelerators.xcu

is used in addition.

The personal settings are in the similar file in the user directory

These files are common for all modules. Each module has a separate section, for example
<node oor:name="">. Shortcut keys, which are available in all modules, are defined in the section <node oor:name="Global">.

Such configuration file is divided into two sections,
<node oor:name="PrimaryKeys"> and <node oor:name="SecondaryKeys">.
If the user defines a shortcut key for a command, which has already got a shortcut key, then the old setting is moved to the SecondaryKeys section and in the PrimaryKeys section the value removed is noted, for example
<node oor:name="RIGHT_SHIFT_MOD1" oor:op="remove"/></node>. You will understand the structure of the file, when you read it.

Each shortcut key is represented by a node element. The above example of AltGr+d to get δ now reads

<node oor:name="D_MOD1_MOD2" oor:op="replace">
  <prop oor:name="Command">
    <value xml:lang="en-US">.uno:InsertSymbol?Symbols:string=δ</value>

In detail:

This sets the desired shortcut. Write first the key identifier, then the modifiers, connected with an underscore.
The value replace is used for new keyboard shortcuts too. For further details on the registry format, see
This is the language of the user interface for which this shortcut is valid.
This is the command to be executed with the shortcut key. It is no longer an attribute, but the content of the value element. Version 3.1 on (Ubuntu) Linux

On Ubuntu Linux, it seems that the functionality of the Alt-Gr key can't be modified by OpenOffice. Therefore D_MOD1_MOD2 (=ALT-Gr) won't work. However, D_MOD2 for the standard ALT key (on the left side of the long space key) works well as described in the section on OOo 3.1 above.

Accelerators.xcu can be found in the home directory of the user (cd ~),

Administrator rights are required to edit the file. To edit it with GEdit, a GUI based editor, use the 'sudo' command to get administrator rights (sudo gedit Accelerators.xcu)

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages