18

I want to implement an addition key layer, so that I can access non-alphanumeric keys without having to move my wrists.

I've been using Autokey for this purpose, but the experience was unsatisfactory: it had occasional lags and let original keystrokes slip into certain apps.

So I need a low-level solution.

3
  • you might have to create custom virtual input driver to do this which i would guess would be written in C
    – Amias
    Oct 14, 2016 at 10:22
  • @Amias, can you please elaborate? Oct 14, 2016 at 11:49
  • you could have a xinput driver that runs the normal keyboard driver but interprets the keystrokes before passing them on to xorg , this would give you complete control but would be a moderately complex couple of days work for a C programmer.
    – Amias
    Oct 14, 2016 at 15:55

3 Answers 3

13

Give a combination of xbindkeys and xvkbd a try. xbindkeys listens for the keys and sends the translation to xvkbd.

sudo apt-get install xbindkeys xvkbd
xbindkeys --defaults > ~/.xbindkeysrc

Open .xbindkeysrc in your favourite editor. I commented everything else out, but it's good to refer to if required.

To check it out, I tried mapping Ctrl+; to Ctrl+V.

"xvkbd -xsendevent -text "\Cv""
   control + semicolon

I expect you're after something like this:

"xvkbd -xsendevent -text "\C\S\[Left]""
  Super+Control+Shift+J

Save the file, then run xbindkeys.

In order to reload any configuration changes, I killed the xbindkeys process then restarted.

xbindkeys syntax

I worked out the key combination by using a GUI for xbindkeys

sudo apt-get install xbindkeys-config
xbindkeys-config

Once you run that, press Get Key for the combination to put into the second line of your .xbindkeysrc file.

xvkbd syntax

From the manual:

\r - Return
\t - Tab
\b - Backspace
\e - Escape
\d - Delete
\S - Shift (modify the next character; please note that modify with ``\S'' will be ignored in many cases. For example, ``a\Cb\ScD\CE'' will be interpreted as a, Control-b, c, Shift-D, and Control-Shift-E.)
\C - Control (modify the next character)
\A - Alt (modify the next character)
\M - Meta (modify the next character)
\[keysym] - the keysym keysym (e.g., \[Left]), which will be processed in the similar matter with other general characters
\{keysym} - the keysym keysym (e.g., \{Left}), which will be processed in more primitive matter and can also be used for modofier keys such as Control_L, Meta_L, etc.; also, \{+keysym} and \{+keysym} will simulate press and release of the key, respectively [Version 3.3]
\Ddigit - delay digit * 100 ms
\xvalue - move mouse pointer (use "+" or "-" for relative motion)
\yvalue - move mouse pointer (use "+" or "-" for relative motion)
\mdigit - simulate click of the specified mouse button

Love to hear how it works out and if the combination was fit for your purpose. It looks good as a keymapper, but not necessarily a macro runner.

1
  • Hey @MarkHewitt! Thank you so much for the detailed response! Unfortunately, this doesn't work for me very well: the original keypress keeps coming through, which ruins the whole thing. Oct 30, 2016 at 12:03
0

I think you can find the solution here (because Xorg is the low-level-est layer...): https://wiki.archlinux.org/index.php/Keyboard_configuration_in_Xorg

EDIT: for what I've understood you need to add the option lv3:win_switch in your .conf file

2
0

You can use the remapper deamon keyd for this purpose. See this answer for installation, usage and tips.

You can use it for the exact behavior of your titles example, but for simplicity, I the follwing just uses space to activate a movement layer if something else is pressed while space is held down, else it inserts a space.

After installation, use the config below:

[ids]

*

[main]

# set the behavior of space (you could also use a timeout):
space = overload(spacemove,space)

# this defines the space layer, the function of keys when space is held
# all non-described keys act as in the layer [main]
[spacemove]
i = up
k = down 
j = left
l = right

keyd is very versatile, stable and fast.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .