Welcome Interweb traveler.
In the last few weeks I decided to tackle the lack of options in Wayland/Weston1 to configure a keyboard's keys as "dual role".
Probably I should do a quick recap to explain why I need this kind of machinery. In the last few years I grew annoyed with standard staggered keyboards based on an ancient design that has no right to exist in this day and age.
What I can't stand is the horizontal stagger itself, as if they were still using mechanical levers from the steam age, but also the lack of easily reachable modifiers, as Ctrl and Alt keys in a default layout are probably in the most inconvenient place, at the side of the uselessly humongous space bar.
When in the past I've been stuck with a non replaceable keyboard I settled on using a little utility called Xcape to configure the space bar to act as a space when tapped and as a Ctrl modifier when pressed with another key, what's called a "dual role" or "tap and hold" key. Pressing two keys at the same time is called chording, like in music.
Well, I also added left paren to left Shift, right paren to right Shift, and Escape to Capslock, as in Emacs complex combinations like Meta-Ctrl-somethingelse could be simplified by tapping Escape and then doing a plain Ctrl chord instead of doing a more awkward three-key chord2.
Anywho, Xcape is a little cumbersome to configure and to use as there's a little delay that's used to discriminate between one of the two roles, also it's more evident when one types fast enough, but the biggest showstopper lies in its underlying operations as it taps directly into X11 and that's a big no-no under Wayland.
So doing a documentation survey on evdev to tackle the problem myself, I stumbled on a little and relatively unknown utility called evdoublebind that allegedly already did what I was looking for.
Well, it needs a proper reading of the documentation and because Gnome lacks support for customized XKB rules it also requires modifying the system XKB file directly — /usr/share/X11/xkb/rules/evdev. On Debian I suggest using dpkg-divert to preserve it in case of upgrade — but at least now I've learned how to build a keyboard description file using XKB.
After a few weeks of usage I could say I'm a happy camper, it's extremely reliable as I've never found the keyboard unable to type space characters after resuming the notebook from sleep — as it sometimes happened previously with Xcape — and I have to say that I haven't mistyped a single space, nor have I changed the way I type like when I was using Xcape.
In conclusion, to the reader with my same requirements who followed along this far, I can give my two thumbs up to evdoublebind wholeheartedly.