6

Like many smaller keyboards, my laptop is missing a dedicated numpad and I use a TKL (ten-key-less) keyboard on my desktop for ergonomic reasons.

I can generally type without looking at my keyboard, but I am unable to blindly type numbers via the number row. That's why I thought of converting the left side of my keyboard into a higher-level numpad (e.g. Z = 0, X = 1. C = 2, V = 3, S = 4 and so on).

Another advantage of this would be the possiblity to quickly type numbers without taking the right hand off the mouse or moving the left hand across the keyboard at all.

Now I'm looking for a way to remap those keys to "create" the numpad, which should be independent of the desktop environment, as I'm using multiple ones constantly. Also, the mapping should be portable, so that I can set it up once and enable it on different keyboards/machines.

How could this be accomplished?

Prototype700
  • 1,120

3 Answers3

1

I am into custom keyboards running QMK and such which allows to redefine every key and allows advanced behaviours such as layers. I recentley came across Kmonad which is a software tool which allows most of the same features. I haven't tried it myself, but this should allow you to hold down or toggle a key to activate a layer on which you can map numbers to the left side of the keyboard.

Here is a link to the github; https://github.com/david-janssen/kmonad

I think Kmonad is also included in a lot of recent distros so it might already be available in APT.

DK88
  • 66
1

You have already mentioned that you can edit /usr/share/X11/xkb/symbols/, I think that this is the most portable option and the one that has worked for me in many linux distributions without needing to install anything. I found some issues in Android Studio but not with the numpad. Most software including browsers and DuckDuckGo work as intended.

If you are willing to give another try, I use Alt Gr and the right hand for the numpad. I use the left hand for other keys like Home, End, del... and these are even more useful than the numpad for me.

Create a new language making a file like /usr/share/X11/xkb/symbols/aa based on the language you normally use.

in the file /usr/share/X11/xkb/rules/evdev.xml

sudo gedit /usr/share/X11/xkb/rules/evdev.xml

before </layoutlist> add this text

<layout>
  <configItem>
    <name>aa</name>
    <shortDescription>Prototype700</shortDescription>
    <description>Prototype700</description>
    <languageList>
      <iso639Id>eng</iso639Id>
    </languageList>
  </configItem>
  <variantList/>

And choose that language as your default one. Below the one I use, based on xkb/symbols/gb

// based on a keyboard map from an 'xkb/symbols/gb' file

default partial alphanumeric_keys xkb_symbols "Prototype700" {

// Describes the differences between a very simple en_US
// keyboard and a very simple U.K. keyboard layout defined by
// Prototype700

include &quot;latin&quot;

name[Group1]=&quot;English (UK)&quot;;

key &lt;AE02&gt;  { [         2,   quotedbl,  twosuperior,    oneeighth ] };
key &lt;AE03&gt;  { [         3,   sterling, threesuperior,    sterling ] };
key &lt;AE04&gt;  { [         4,     dollar,     EuroSign,   onequarter ] };

key &lt;AC11&gt;  { [apostrophe,         at, dead_circumflex, dead_caron] };
key &lt;TLDE&gt;  { [     grave,    notsign,          bar,          bar ] };

key &lt;BKSL&gt;  { [numbersign, asciitilde,   dead_grave,   dead_breve ] };
key &lt;LSGT&gt;  { [ backslash,        bar,          bar,    brokenbar ] };

key &lt;AD01&gt; {    [     q,    Q,    Escape,       Adiaeresis ]    };
key &lt;AD02&gt; {    [     w,    W,    Delete,            Aring ]    };
key &lt;AD03&gt; {    [     e,    E,    Up,           Eacute ]    };
key &lt;AD04&gt; {    [     r,    R,    Prior,       registered ] };
key &lt;AD05&gt; {    [     t,    T,    Prior,            THORN ] };
key &lt;AD06&gt; {    [     y,    Y       ]   };
key &lt;AD07&gt; {    [     u,    U,    7,           Uacute ] };
key &lt;AD08&gt; {    [     i,    I,    8,           Iacute ] };
key &lt;AD09&gt; {    [     o,    O,    9,           Oacute ] };
key &lt;AD10&gt; {    [     p,    P       ]   };
key &lt;AD11&gt; {    [ bracketleft,  braceleft   ]   };
key &lt;AD12&gt; {    [ bracketright, braceright  ]   };

key &lt;AC01&gt; {    [     a,    A,    Home,           Aacute ]  };
key &lt;AC02&gt; {    [     s,    S,    Left,          section ]  };
key &lt;AC03&gt; {    [     d,    D,    Down,              ETH ]  };
key &lt;AC04&gt; {    [     f,    F,    Right,                F ] };
key &lt;AC05&gt; {    [     g,    G,    End,                G ]   };
key &lt;AC06&gt; {    [     h,    H       ]   };
key &lt;AC07&gt; {    [     j,    J,    4,                J ] };
key &lt;AC08&gt; {    [     k,    K,    5,               OE ] };
key &lt;AC09&gt; {    [     l,    L,    6,         Ooblique ] };
key &lt;AC10&gt; {    [ semicolon,    colon,     ntilde,           Ntilde ]   };
key &lt;AC11&gt; {    [ apostrophe,   quotedbl,  dead_acute, dead_diaeresis   ]   };

key &lt;AB01&gt; {    [     z,    Z,    BackSpace,               AE ] };
key &lt;AB02&gt; {    [     x,    X,    Insert,                X ]    };
key &lt;AB03&gt; {    [     c,    C       ]   };
key &lt;AB04&gt; {    [     v,    V,    Next,                V ]  };
key &lt;AB05&gt; {    [     b,    B,    Next,                B ]  };
key &lt;AB06&gt; {    [     n,    N,    0,           Ntilde ] };
key &lt;AB07&gt; {    [     m,    M,    1,               mu ] };
key &lt;AB08&gt; {    [     comma,    less, 2,           less ]   };
key &lt;AB09&gt; {    [    period,    greater, 3,     greater ]   };
key &lt;AB10&gt; {    [     slash,    question    ]   };

include &quot;level3(ralt_switch_multikey)&quot;

};

If you use Windows machines, Autohotkey is your friend. You probably know that, since you are familiar with Autokey.

Katu
  • 3,663
0

For my own reference and if somebody is still looking for a way to accomplish this:

After apparently almost five years and some experiments, as well as trying to live with the number row, I recently had another shot at this.

What I had tried previously:

autokey - Didn't work, because while the remapping was possible, some input fields on websites or more advanced software would not accept the numbers. I do not know if this was due to autokey's implementation or if some programs are listening to modifier keys and overwrite the keyboard layer switching.

xmodmap - Worked to some extent, but unfortunately KDE Plasma has serious issues with it and would crash when a custom mapping was enabled. Also, if the session is closed or the keyboard gets disconnected, the mapping has to be applied again manually, which became a hassle for me repeatedly.

So, I had another look at the xkb extension and found out that there actually is a way to accomplish this:

My previous issue (also the one with Katu's solution) was that I live in Europe and need to use predefined 3rd-level AltGr characters like é or ä sometimes, which means that I couldn't simply free those key levels without moving these characters to less logical positions.

However, xkb actually supports a 5th level mapping with its own modifier key that enables another keyboard layer altogether, allowing to enter up to 8 symbols per key, depending on the combination of modifiers.

I probably haven't found this option before, just because I searched for a "4th level" instead of a 5th and none of the language configs I saw had additional characters defined beyond 3rd/4th level.

To enable 5th level mapping on any language config, just two lines need to be added:

key.type[Group1] = "EIGHT_LEVEL";
include "level5(rwin_switch_lock)"

The key.type parameter enables additional levels from 5-8 for each key config while the line include "level5()" sets the key that acts as the modifier to access those additional levels. I added rwin_switch_lock in the example, because that's what I chose to access my numpad, but there are other default options as defined in /usr/share/X11/xkb/symbols/level5:

rctrl_switch (Right Control)
lsgt_switch (Lesser/Greater key on European keyboards)
ralt_switch (Right Alt/AltGr)
caps_switch (Caps Lock)

These also exist as locking keys, including Super L, although these keys do act like layer switches for me too (only while being pressed), so I'm unsure of the difference:

lsgt_switch_lock (Lesser/Greater key on European keyboards)
lwin_switch_lock (Super L)
ralt_switch_lock (Right Alt/AltGr)
rwin_switch_lock (Super R)

You can also add modifier_mapping to turn every key into the level 5 modifier switch by changing its only function to { [ ISO_Level5_Shift ] }.

After adding the key.type line and including a modifier switch, any key in the language config can be extended with up to 8 levels of symbols, like so:

key <AD01> { [         q,   Q,               oe,                OE, 7 ] };
key <AD02> { [         w,   W,    dead_abovedot,     dead_abovedot, 8 ] };
key <AD03> { [         e,   E,           eacute,            Eacute, 9 ] };
key <AC01> { [         a,   A,           aacute,            Aacute, 4 ] };
key <AC02> { [         s,   S,           ssharp,         0x1001E9E, 5 ] };
key <AC03> { [         d,   D,              eth,               ETH, 6 ] };
key <LSGT> { [ backslash, bar,       dead_grave,        dead_acute, 0, plus ] };
key <AB01> { [         z,   Z, leftanglebracket, rightanglebracket, 1, minus ] };
key <AB02> { [         x,   X,         multiply,       approximate, 2, multiply ] };
key <AB03> { [         c,   C,     dead_cedilla,           cedilla, 3, division ] };

In this case, I used the Irish language config (/usr/share/X11/xkb/symbols/ie) as the basis and copied it to /usr/share/X11/xkb/symbols/ie_mod to add the 5th level numpad and I also added basic mathematic operators to the lower row of keys on level 6 (accessed via Super L + Shift).

Afterward, the modified language config file can be included into the list of languages by adding it as an additional layout to /usr/share/X11/xkb/rules/evdev.xml in the <layoutList> section:

<layout>
  <configItem>
    <name>ie_mod</name>
    <shortDescription>IE Mod</shortDescription>
    <description>Irish Modded</description>
    <countryList>
      <iso3166Id>IE</iso3166Id>
    </countryList>
    <languageList>
      <iso639Id>eng</iso639Id>
    </languageList>
  </configItem>
</layout>

(as also per Katu's answer)

The great advantage of this approach is that this mapping works everywhere, survives session logouts and even works on the lockscreen, so it is possible to enter user passwords this way.

Caveat: I am unsure if these edits will survive (major) updates and it's not possible to add a custom language config this way without root access. If someone knows a way to make this more portable and without requiring access to the system directories, please do tell me. I've tried adding the language config to the home directories via this guide, but it didn't show up. I also tried deleting the xkb cache, but that didn't work, either.

Prototype700
  • 1,120