5

I'm currently trying to create some custom keyboard-shortcut mappings with different functions.

For this, I would like the spacebar to act as a modifier / function key (like Ctrl, Shift, Alt, etc.), because it covers a large area and gives me a lot of options to reach many key combinations comfortably.

My idea is to make Shift + Space execute the Super-modifier (probably either Super L or Super R) and then just build all of my custom shortcuts with Super. (The spacebar would just act as a kind of physical extension to the Super-key locations while keeping the regular ones.)

I have already tried to edit /usr/share/X11/xkb/symbols/pc, in which the default spacebar functionality is just:

key <SPCE> {        [       space           ]       };

This is great, because I can simply add a comma and another parameter to get the second-level functionality, like this:

key <SPCE> {        [      space, Super_L   ]       };

However, then the spacebar stops working completely.

Update: I have been able to make the spacebar work normally and execute Hyper L on the second level, but there's a problem creating multiple shortcuts with it, since some software will only see it as Shift + Hyper L and not register the Hyper-modifier correctly.

Is it possible to have the spacebar work normally and act as a modifier key on the second level?

1 Answer 1

2

So the closest thing I have found is a fairly complex set of gymnastics with xmodmap and xcape as detailed in the examples section of the xcape README.

Here's the excerpt:

# Map an unused modifier's keysym to the spacebar's keycode and make it a
# control modifier. It needs to be an existing key so that emacs won't
# spazz out when you press it. Hyper_L is a good candidate.
spare_modifier="Hyper_L"
xmodmap -e "keycode 65 = $spare_modifier"
xmodmap -e "remove mod4 = $spare_modifier" # hyper_l is mod4 by default
xmodmap -e "add Control = $spare_modifier"

# Map space to an unused keycode (to keep it around for xcape to
# use).
xmodmap -e "keycode any = space"

# Finally use xcape to cause the space bar to generate a space when tapped.
xcape -e "$spare_modifier=space"

I tried this and I was able to get space to act like the Super_L modifier when used modifier style, but I found the timing interfered with typing regular spaces normally and I disabled this the next day. There may be some way to dial the timings and make it work but I haven't dug into the details there yet.

3
  • And just for awareness on macos there's a third party utility called SpaceLauncher that does seem to effectively enable using spacebar as a modifier key. May 8, 2020 at 15:10
  • 1
    I just tried this. While it seems to work very good at first, weird things started happening soon for me as well. There's a certain delay with the spacebar that causes commands to be executed well after releasing the key and also normal spaces sometimes carry over to what is typed afterwards, just like the readme states, there seems to be a performance issue, unfortunately. If that weren't the case, it would be perfect... As for "SpaceLauncher", I wasn't able to find anything on that so far (or, I found a lot of things, but nothing that matched, unless you mean the OSX app - I use Linux.) May 9, 2020 at 11:36
  • Right. So far I've only found xcape for linux which is problematic and spacelauncher for osx which works well. May 11, 2020 at 17:23

You must log in to answer this question.

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