Creating your own keyboard
Prev
Next

Creating your own keyboard

You can create your own keyboards by creating keyboard files. Currently KTouch doesn't have a keyboard editor but it is still pretty easy to define your own keyboard. It doesn't require much more than a little math to work out the geometry and some time. Best is to start with an existing keyboard file, create a copy for your keyboard layout and simply adjust the lines.

Currently keyboard files are plain UTF-8 encoded text files. In one of the next version of KTouch keyboard data will be stored in XML files, too. Therefore I'll only briefly explain the structure of a keyboard file.

A keyboard file usually starts with a header including some information about the author and type of the keyboard.

####################################################
#    KTouch
#    Keybord layout file for german keybord layout
#    Code=UTF-8
####################################################

All lines starting with a hash character '#' are considered comments. After the header section a block of so called “finger keys” follows, indicating the resting positions for all 8 fingers.

#
#          Unicode  KeyChar  x    y
#
FingerKey  97       A        18   20
FingerKey  115      S        28   20
FingerKey  100      D        38   20
FingerKey  102      F        48   20
FingerKey  106      J        78   20
FingerKey  107      K        88   20
FingerKey  108      L        98   20
FingerKey  246      Ö        108  20

Keys have the default dimensions of 8 units, so using a grid of 10 units gives a normal looking keyboard. The first number is the unicode character code as decimal number. The KeyText is the text printed on the key encoded as UTF-8 (automatic under newer Linux® versions, just make sure your editor saves files as UTF-8 format).

The next section contains special keys, which are - apart from BackSpace and Enter - just decorative.

#
#           Unicode  KeyText    x     y     Width Height
#
ControlKey  260      Tab        0     10    15    10
ControlKey  13       Enter      138   20    12    10
ControlKey  258      Shift      123   30    27    10
ControlKey  264      AltGr      120   40    15    10
ControlKey  265      Ctrl       135   40    15    10
ControlKey  263      Alt        15    40    15    10
ControlKey  262      Strg       0     40    15    10
ControlKey  32       Leertaste  30    40    90    10
ControlKey  257      Shift      0     30    13    10
ControlKey  259      CapsLock   0     20    18    10
ControlKey  8        BackSpace  130   0     20    10

The text you specify for the key is printed completely on the keyboard. However, for the keytexts “Shift”, “CapsLock”, “Tab”, “BackSpace” and “EnterKTouch draws the appropriate symbols. Hence you can use these keytexts regardless of the language. The other keytexts like Ctrl or Alt need to be translated though. The geometry of the control keys can be any rectangle, defined by upper left x and y coordinates and width and height.

The next section contains all characters on the keyboard (except the already defined finger keys) that can be typed without pressing shift.

#
#          Unicode  KeyChar   x    y      FingerKeyUnicode
#
NormalKey  94       ^         0    0      97
NormalKey  49       1         10   0      97
NormalKey  50       2         20   0      115
NormalKey  51       3         30   0      100
NormalKey  52       4         40   0      102
NormalKey  53       5         50   0      102
NormalKey  54       6         60   0      102
.
.
.
NormalKey  46       .         103  30     108
NormalKey  45       -         113  30     246

The definition of these primary keys or chars is pretty much the same as for the finger keys, but they include an additional property. The last unicode character code identifies the associated finger key. Basically which finger has to be used to press this key.

The next and last section in a keyboard layout defines all keys that are pressed by using a modifier key such as the shift key.

#
#           Unicode   TargetUnicode   FingerUnicode   ControllUnicode    
Comment
#
HiddenKey   65        97              97              258                 #A
HiddenKey   66        98              102             258                 #B
HiddenKey   67        99              100             258                 #C
HiddenKey   68        100             100             258                 #D
.
.
.
HiddenKey   124       60              97              264                 #|
HiddenKey   64        113             97              264                 #@

The “hidden keys” are really controlling what should happen on the keyboard when you type a certain character. The first unicode number is the character code of the character you define. The second number is the character code of the key on the keyboard (one of the already defined normal keys). The third number indicates a finger key (where does the finger rest that is needed to type the key) and the last number indicates the modifier key you need to press to get this character.

Let's look@an example:

You want to define the uppercase 'R' character. It has the unicode 82. The character obtained when the 'R' key is pressed without modifier is the small 'r' with the unicode 114. The finger for the 'R' rests over the 'f' key which has the unicode 102. And in order to get the 'R' you need to press the right (or left) shift key which has the code 264 (this is actually not a unicode but the code obtained from a keypress event of QT). Note that the identification of controll keys will likely change in the next version of KTouch. But for now you can use the codes used in other keyboard files.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team