Difference between revisions of "Documentation/How Tos/Edit Keyboard Configuration File"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Getting ALT-key in short cuts. Only for WinXp, need to be tested and extended for other OS.)
 
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== Customize Keybord by Editing a Configuration File ==
+
{{NeedsRework|EN}}
 +
{{NL/Documentation/Windows|Windows related content}}
  
Up to OOo3.0 it is not possible to define a short cut key which includes the ALT-key using the Customize dialog, {{Bug|4756}}. But you must edit the configuration file to get such a short cut. This is a description, how to do it. It has only been tested for WinXP.
+
== OpenOffice.org 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, {{Bug|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.
 
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.
Line 10: Line 13:
 
<pre><..>\user\config\soffice.cfg\global\accelerator\<language code>\current.xml</pre>
 
<pre><..>\user\config\soffice.cfg\global\accelerator\<language code>\current.xml</pre>
  
Older versions of OOo might not have this files by default. If they are missing, goto Tool | Customize | Keyboard and change something. Then the files will be generated.
+
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.
  
 
# Close OOo and close quickstarter.
 
# Close OOo and close quickstarter.
Line 30: Line 33:
 
You will notice that the lines have all the same structure.
 
You will notice that the lines have all the same structure.
  
<pre>accel:item</pre>  Each such line defines a single short cut key.
+
<pre>accel:item</pre>  Each such line defines a single shortcut key.
 
<pre>accel:code="KEY_Q"</pre>
 
<pre>accel:code="KEY_Q"</pre>
 
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.''
 
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.''
Line 46: Line 49:
 
Inside the quotes stands a Command URL. In older OOo versions the command URL could be build as <pre>"slot:<number>"</pre> but that way should not be used for newer versions, if a ".uno" form exists. Therefore always use <pre>".uno:<command>"</pre>
 
Inside the quotes stands a Command URL. In older OOo versions the command URL could be build as <pre>"slot:<number>"</pre> but that way should not be used for newer versions, if a ".uno" form exists. Therefore always use <pre>".uno:<command>"</pre>
  
You find those commands in the document [http://framework.openoffice.org/files/documents/25/2570/commandsReference.html] in the first column or in the above mentioned document "StarOFfice 8 Administration Guide".
+
You find those commands in the document [http://framework.openoffice.org/files/documents/25/2570/commandsReference.html] 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 "&delta;" (Greek delta). Or look at the existing lines in the configuration files. Perhaps you can alter a parameter?
 
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 "&delta;" (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 "&delta;" the complete Command URL is ".uno:InsertSymbol?Symbols:string=&delta;".
+
Such parameters follow the command after a <tt>?</tt>. For inserting the character "&delta;" the complete Command URL is ".uno:InsertSymbol?Symbols:string=&delta;".
 +
 
 +
The first part after the character <tt>?</tt> is the name of the parameter. It is followed be the character <tt>:</tt>. After this colon the type of the parameter value is given and then after the character <tt>=</tt> the value itself.
 +
 
 +
For example, inserting unformatted text is the command
 +
".uno:ClipboardFormatItems?SelectedFormat:short=1".
  
 
Modifier keys and command URL may be exchanged.
 
Modifier keys and command URL may be exchanged.
Line 56: Line 64:
 
The complete line for inserting the special character &delta; when pressing the keys AltGr (German) and D together is then
 
The complete line for inserting the special character &delta; when pressing the keys AltGr (German) and D together is then
 
<pre><accel:item accel:code="KEY_D" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertSymbol?Symbols:string=δ" /></pre>
 
<pre><accel:item accel:code="KEY_D" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertSymbol?Symbols:string=δ" /></pre>
 +
 +
== OpenOffice.org Version 3.1 ==
 +
 +
From OOo version 3.1 an <tt>xcu</tt> format is used for the keyboard configuration file. This format is common for other configurations too. The corresponding schema is defined in <pre>...\OpenOffice.org 3\Basis\share\registry\schema\org\openoffice\Office\Accelerators.xcs</pre>
 +
The default keyboard shortcuts, which are valid for all users, are defined in the file<pre>...\OpenOffice.org 3\Basis\share\registry\data\org\openoffice\Office\Accelerators.xcu</pre>
 +
If you use another local than en-US, for example de, then the file
 +
<pre>...\OpenOffice.org 3\Basis\share\registry\res\de\org\openoffice\Office\Accelerators.xcu</pre>
 +
is used in addition.
 +
 +
The personal settings are in the similar file in the user directory <pre>..\user\registry\data\org\openoffice\Office\Accelerators.xcu</pre>
 +
 +
These files are common for all modules. Each module has a separate section, for example<br /> <tt><node oor:name="com.sun.star.text.TextDocument"></tt>. Shortcut keys, which are available in all modules, are defined in the section <tt><node oor:name="Global"></tt>.
 +
 +
Such configuration file is divided into two sections,<br /> <tt><node oor:name="PrimaryKeys"></tt> and <tt><node oor:name="SecondaryKeys"></tt>.<br /> 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<br /> <tt><node oor:name="RIGHT_SHIFT_MOD1" oor:op="remove"/></node></tt>. 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 &delta; now reads
 +
<pre>
 +
<node oor:name="D_MOD1_MOD2" oor:op="replace">
 +
  <prop oor:name="Command">
 +
    <value xml:lang="en-US">.uno:InsertSymbol?Symbols:string=δ</value>
 +
  </prop>
 +
</node>
 +
</pre>
 +
 +
In detail:
 +
 +
<pre>oor:name="D_MOD1_MOD2"</pre> This sets the desired shortcut. Write first the key identifier, then the modifiers, connected with an underscore.
 +
 +
<pre>oor:op="replace"</pre> The value ''replace'' is used for new keyboard shortcuts too. For further details on the OpenOffice.org registry format, see http://util.openoffice.org/common/configuration/oor-document-format.html
 +
 +
<pre>xml:lang="en-US"</pre> This is the language of the user interface for which this shortcut is valid.
 +
 +
<pre>.uno:InsertSymbol?symbol:string=δ</pre> This is the command to be executed with the shortcut key. It is no longer an attribute, but the content of the value element.
 +
 +
== OpenOffice.org 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 ~), .openoffice.org/3/user/registry/data/org/openoffice/Office/
 +
 +
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)
 +
 +
{{PDL1}}
 +
[[Category:Documentation/How Tos/Installation]]
 +
[[Category:Documentation/Setup]]
 +
[[nl:NL/Documentation/How_Tos/Edit_Keyboard_Configuration_File]]

Latest revision as of 13:55, 30 June 2018

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

Documentation windows.png Windows related content


OpenOffice.org 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 "OpenOffice.org 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="http://openoffice.org/2001/accel" xmlns:xlink="http://www.w3.org/1999/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.

accel:item
Each such line defines a single shortcut key.
accel:code="KEY_Q"

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".

accel:mod1="true"
That is the CRTL-key.
accel:mod2="true"
That is the ALT-key.
accel:shift="true"
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

xlink:href=".uno:Quit"
will close OOo.


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

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=δ" />

OpenOffice.org 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
...\OpenOffice.org 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
...\OpenOffice.org 3\Basis\share\registry\data\org\openoffice\Office\Accelerators.xcu

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

...\OpenOffice.org 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
..\user\registry\data\org\openoffice\Office\Accelerators.xcu

These files are common for all modules. Each module has a separate section, for example
<node oor:name="com.sun.star.text.TextDocument">. 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>
  </prop>
</node>

In detail:

oor:name="D_MOD1_MOD2"
This sets the desired shortcut. Write first the key identifier, then the modifiers, connected with an underscore.
oor:op="replace"
The value replace is used for new keyboard shortcuts too. For further details on the OpenOffice.org registry format, see http://util.openoffice.org/common/configuration/oor-document-format.html
xml:lang="en-US"
This is the language of the user interface for which this shortcut is valid.
.uno:InsertSymbol?symbol:string=δ
This is the command to be executed with the shortcut key. It is no longer an attribute, but the content of the value element.

OpenOffice.org 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 ~), .openoffice.org/3/user/registry/data/org/openoffice/Office/

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