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.
- 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.
- 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).
- 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.