Use a single key both as a modifier and to send a normal keystroke

keyboard-layout

I'm using Karabiner on Mac OS X to make some of my keys
work as half modifiers: for ex. tapping enter is enter but
holding it is meta. Is it easy to do the same in Linux?

PS. I mean: I want to be able to use enter both as a modifier key and as enter, depending on whether it is held or pressed and released. (Not the same as sticky keys.)

Best Answer

Two options

I use At Home Modifier to achieve this. The developer also suggests xcape as an alternative.

Comparison

The developer of At Home Modifier says the following about xcape.

Pros: Don't have to recompile for each update of X server or xf86-input-evdev. The code is smaller.

Cons: May not be available for Wayland, since XTest and Record extensions may be dropped. Probably interferes with other softwares which use Record Extension, e.g. AutoKey or xnee.

My experience

I've used both. Personally, I prefer At Home Modifier for a few reasons.

  1. It's very easy to set up At Home Modifier with an xorg.conf rule. Hence, it can apply to specific keyboards, leaving other keyboards alone.
  2. At Home Modifier acts at a system-level, meaning that it works better in multi-user environments (unless you want different settings, in which case xcape might be more appropriate).
  3. At Home Modifier maps the modifier key (e.g. Meta) to the "tapped" key (e.g. Enter), whereas xcape does the opposite. When X isn't running, e.g. on the console or in the display manager, I'd prefer to have access to the "real" fallback key, i.e. Enter. I'd use that much more frequently in these situations.

The first pro of xcape quoted above may or may not affect you, depending on your distro. If you update Ubuntu immediately (I've done this), you may need to recompile At Home Modifier yourself if the ppa lags behind (it's lagged a few months at least once). If you use Arch Linux, the AUR package is up to date and easy enough to bump the version number. The old version is generally compatible anyway.

Related Question