Hot Keys and non-latin keyboards

From MEPIS Documentation Wiki

Jump to: navigation, search

!!! Warning! The info contained in this article pertains to older versions of MEPIS !!!

Originally this was posted in the Linspire forum by Moscowtime, and is edited and reproduced here because of its general application.

KDE gives a very convenient way to switch between keyboard layouts - US-English and Russian in my case. The icon in taskbar shows me the country flag, and I can click on this icon to switch instantly between the layouts. No problems here.

However, once I switch to Russian layout, all my Hot Keys became inoperative. I cannot use anymore Ctrl-C for copying, Ctrl-X for cutting or Ctrl-V for pasting. I cannot use Cntrl-L, Cntrl-R and Cntrl-E for justification, Cntrl-B and Ctrl-U for Bold and Underline, etc. Every text-editing and word-processing application behaves this way. Sure, I can still use the "Edit" menu, but Hot Keys are so much more convenient!

Searches revealed that this problem is common to all distributions, and that it has its roots in the "xkb" configuration files. There is an incredible variety of xkb manuals and descriptions which contain bits of information that led me to the following workaround that works amazingly well, given the profound ignorance of the author.

The keywords here are "modifiers", "levels" and "chooser". All other arcane terminology will be explained as it will appear, but these 3 terms must be explained beforehand.

Intuitively the concept of MODIFIER is clear: if you press a key on the keyboard, you get some symbol, if you press this key together with some modifier key, you get some different symbol. The obvious example is "Shift" modifier, which switches the keyboard from lowercase to uppercase. Other well-known modifiers are "Ctrl", "Alt", and "Win-Key".

In general xkb provides 1) the possibility to use 8 different modifiers, bringing the total number of combinations to 256, and 2) the possibility to map any modifier to any key on the keyboard, including also mapping of several modifiers to one single key, and mapping of a single modifier to several different keys.

The concept of LEVELS is best explained with an example. Let's open the /usr/share/X11/xkb/symbols/ru (this is MEPIS 7 location, other systems may use /etc/X11/xkb/symbols/pc/ru) file (Russian layout) in a text editor.

   key	<AD01> {	[ Cyrillic_shorti, Cyrillic_SHORTI	]	};
   key	<AD02> {	[    Cyrillic_tse,    Cyrillic_TSE	]	};
   key	<AD03> {	[      Cyrillic_u,	Cyrillic_U	]	};
   key	<AD04> {	[     Cyrillic_ka,     Cyrillic_KA	]	};  

This fragment describes the keys located in the "D" row - these are the "qwer" keys, each one producing some Cyrillic symbol when pressed. Actually each key can produce 2 symbols - a lowercase one and uppercase one, just as it is conventional for English typing. Switching between lowercase LEVEL and uppercase LEVEL happens under control of "Shift" MODIFIER. In this case Shift modifier works as SECOND LEVEL CHOOSER.

To understand CHOOSER, let's look at another fragment, this time from /etc/X11/xkb/symbols/pc/ie file (Irish layout).

   key <AD01> { [            q,           Q,                   oe,                   OE ] };
   key <AD02> { [            w,           W,        dead_abovedot,        dead_abovedot ] };
   key <AD03> { [            e,           E,               eacute,               Eacute ] };
   key <AD04> { [            r,           R,           registered,            0x1002030 ] };

Here each key can produce 4 different symbols - so obviously we need a second modifier to access the additional possibilities. Usually either "Alt" or "WinKey" modifier is used for this purpose, and quite naturally the modifier used is called THIRD LEVEL CHOOSER. The important thing is that this modifier can be programmed in KDE Control center (ControlCenter -> Regional@Accessibility -> KeyboardLayouts -> xkbOptions).

Now a couple of words about "Ctrl" modifier. It must be well understood that "Ctrl" IS NOT A MODIFIER in the conventional sense. It is the INSTRUCTION to the xkb machinery to perform some additional processing of the symbol ALREADY SELECTED, and to render at the output the result of this processing. For Latin symbols these results are tabulated:

 Ctrl-a = 0x01
 Ctrl-b = 0x02
 Ctrl-c = 0x03
 Ctrl-x = 0x18
 Ctrl-y = 0x19
 Ctrl-z = 0x1A
 Ctrl-[ = 0x1B

For Cyrillic and other non-Latin symbols the results are undefined.

This brought me to the solution of the problem. First, it was necessary to arrange the access to Latin symbols in the /etc/X11/xkb/symbols/pc/ru file. The changes were as follows (compare with the fragment above):

   key	<AD01> {	[ Cyrillic_shorti, Cyrillic_SHORTI,	q,	Q	]	};
   key	<AD02> {	[    Cyrillic_tse,    Cyrillic_TSE,	w,	W	]	};
   key	<AD03> {	[      Cyrillic_u,	Cyrillic_U,	e,	E	]	};
   key	<AD04> {	[     Cyrillic_ka,     Cyrillic_KA,	r,	R	]	};
   key	<AB05> {	[      Cyrillic_i,	Cyrillic_I,	b,	B	]	};
   key	<AB06> {	[     Cyrillic_te,     Cyrillic_TE,	n,	N	]	};
   key	<AB07> {	[Cyrillic_softsign,Cyrillic_SOFTSIGN,	m,	M	]	};

for all alphabetic keys in order to get access to 26 Latin symbols.

Next came the THIRD LEVEL CHOOSER. This was simple - go to KDE ControlCenter (Settings) -> Regional & Accessibility -> Keyboard Layout, click on the tab Xkb Options, check "Enable xkb options" and check the box "Any WinKey chooses 3-d level" in the category "Third-level Choosers."

So now, when I have Russian layout selected in KDE panel, I am typing Russian symbols. When I need to insert a couple of Latin symbols into Russian text (e.g. IBM or FEDEX), I just press the WinKey and type these symbols. Finally, when I need to apply a HotKey shortcut, I press the WinKey-Ctrl conbination, and all conventional shortcuts are here where I expect them to be:

 WinKey-Ctrl-a = Select All
 WinKey-Ctrl-b = Bold
 WinKey-Ctrl-c = Copy
 WinKey-Ctrl-x = Cut

I consider pressing the additional key a small price to pay for recovered convenience.


Personal tools