HOW-TO:Modify keymaps

From Official Kodi Wiki
Revision as of 09:27, 22 August 2010 by >Jhsrennie (How to create custom key mappings by modifying keyboard.xml)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Quick summary

The keyboard.xml file controls how XBMC reacts to keypresses, that is it determines what action is mapped to what keypress. There are two main reasons for modifying keyboard.xml:

1. you want to change the standard key mappings because of a personal preference

2. you are configuring a Media Center remote control that sends keypresses

You can edit keyboard.xml using any text editor such as Notepad in Windows or gedit in Linux. The location of the file is:

Windows - %APPDATA%\xbmc\userdata\keymaps\keyboard.xml

Linux - $home/.xbmc/userdata/keymaps/keyboard.xml

There is a more detailed discussion of the keyboard.xml file at http://wiki.xbmc.org/index.php?title=Keymap.xml, while the remainder of this article is focussed on the gory details of editing it.

Introduction

All the keypresses that XBMC responds to, for example "P" for "play" and "X" for "stop" are configured in a file called keyboard.xml. Actually there are two keyboard.xml files. There is the system keyboard.xml that contains all the standard key mappings, and each user optionally has their own userdata keyboard.xml that contains just their customised key mappings.

The userdata keyboard.xml only needs to contain additional key mappings, or key mappings that override the defaults in the system keyboard.xml. When XBMC is trying to decide how to respond to a keypress it first looks in the userdata keyboard.xml. If it doesn't find a mapping for the keypress XBMC then looks in the system keyboard.xml. This means that the userdata keyboard.xml is typically quite short because it only needs to define mappings for a few keys.

You can change key mappings by editing the system keyboard.xml, but we strongly recommend you don't do this. The system keyboard.xml is a big complicated file, and if you introduce an error into it you can break all the key mappings. Also any changes you make risk being overwritten if you upgrade XBMC. In general you should only ever edit your userdata keyboard.xml. Even if you make a horrendous hash of this you just need to delete or rename your userdata keyboard.xml to restore the default key mappings.

Where to find keyboard.xml

Windows

The userdata keyboard.xml is kept in %APPDATA%\xbmc\userdata\keymaps\keyboard.xml, where %APPDATA% is an environment variable that varies depending on what version of Windows you use. For example on my PC runnings Windows 7 my %APPDATA% is C:\Users\renniej\AppData\Roaming.

Note that %APPDATA% contains the username ("renniej" in my case). This means that if several different users are using the same PC each user has their own keyboard.xml so changes you make to one user won't affect the others. If you really really want your changes to affect all users you can either (carefully!) edit the system keyboard.xml or you can use portable mode.

To edit your userdata keyboard.xml click Start then Run, or in Win7 click Start then All Programs then Accessories then Run, or press the keyboard shortcut Windows-R, then when the Run dialog opens type in:

notepad %APPDATA%\XBMC\userdata\keymaps\keyboard.xml

If you haven't editing your keyboard.xml before Notepad will ask "Do you want to create a new file?" and you should click Yes.

Linux

The userdata keyboard.xml is kept in $home/.xbmc/userdata/keymaps/keyboard.xml, where once again $home is an enviroment variable. In most text editors like gedit the .xbmc directory won'tbe displayed and you need to enable displaying hidden files.

What to put in keyboard.xml

If you are configuring the myriad of buttons on a Windows Media Center remote control grab a copy of mceremote.zip from http://xbmcmce.sourceforge.net/ as this contains a sample keyboard.xml with all the MCE keypress mappings. There's even a batch file to copy the sample keyboard.xml to your userdata folder. Even if you aren't configuring a remote control, the sample keyboard.xml provides an easy starting point for making your changes.