Extra keys

From MEPIS Documentation Wiki

If you have special keys, buttons, or controls on your laptop or multimedia keyboard that you want to use, you have probably discovered that they don't work by default in MEPIS. However, they can be made to work.

Contents

How keyboards & controllers work

Before explaining how to fix them, it's important to understand how these keyboards and controls work.

Whenever you press a key on the keyboard, a short numeric keycode is generated by the keyboard and sent to the OS.

The code is mapped to a virtual key

The virtual key performs whatever function is assigned to it in the OS -- i.e., printing a letter on the screen, or bringing up a certain program, etc.

So for example, when you press your left shift key, a keycode of "50" is sent to the OS. The OS has keycode "50" mapped to Shift_L, which the OS has been programmed to interpret in all the usual ways that a shift key is interpreted.

What you need to do to get your extra keys working is to tell MEPIS two things:

What keys to map the keycodes from your extra keys or buttons to.

What to do when the mapped keys are pressed.

Getting your keys working

KDE

First, open your system configuration and go to "Regional & Accessibility". Select "Keyboard Layout". Check "Enable keyboard layouts". Check the drop-down list to see if your model of keyboard is there. If so, select it and hit "apply".

hotkey-setup

If that doesn't work, install hotkey-setup from the repositories:

apt-get install hotkey-setup

It is designed to automatically determine your keyboard's model and set up the additional keys.

hotkeys

If that doesn't work, try installing hotkeys from the repositories:

apt-get install hotkeys

Hotkeys does not instantly work "out of the box". You will need to read the manual (type man:hotkeys in konqueror's address bar) and edit /etc/hotkeys.conf to tell hotkeys what model your keyboard is, and what programs or commands you want the extra buttons to perform. You will also need to set up hotkeys to run at login, which you can do with this command:

ln -s /usr/bin/hotkeys ~/.kde/Autostart/hotkeys

The manual way

As a last resort, you can manually set up your keyboard by finding the keycodes of the buttons, assigning them to virtual keys, and then setting up the virtual keys to perform tasks.

* Run xev from the konsole

xev |grep keycode

. If necessary, install xev from the repositories

apt-get install xev

.

This will open a small window with a black square in it. Make sure the window is in focus and push the buttons on your keyboard. You should see entries coming up in your konsole window, something like this (this is for the 'a' key):

state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,

. For each button, write down the number listed after "keycode". In this case it would be '38'.

Become root with "su".

Create the file /etc/X11/Xmodmap and open it in an editor

touch /etc/X11/Xmodmap && kwrite /etc/X11/Xmodmap

For each keycode, assign it to a nonexistant virtual key. The F-keys above F12 are good for this. It will look something like this:

keycode 132 = F13
keycode 133 = F14

Now that you have done this, restart X by logging out and hitting ctrl-alt-backspace.

At this point, your extra buttons will be seen by MEPIS as F13, F14, or whatever virtual keys you assigned. You can then assign these keys as hotkeys in KDE through normal means. For instance, if your keyboard has a "calculator" button which you have assigned to F13 and you want it to open kcalc; open the KDE menu editor, find the entry for kcalc, click "current shortcut key" and hit your calculator key. It would display as "F13".

Remapping the Windows keys

In this example, the left Windows key will be remapped to open KMenu. The bolded terms for the keycode and the command should be changed according to your particular situation.

1) use the xev command to find the keycode for your Windows key - for example, 133