It's been a blast to play around with. Best part is that it travels with the keyboard rather than the OS, so I can plug into a different computer and retain the same layout without needing to install anything.
I've been slowly resetting all my OS hotkeys/shortcuts to their defaults, and customizing the position of those keys on my keyboard instead. Current layout, for reference: https://configure.zsa.io/ergodox-ez/layouts/xbzAL/latest/0
XInput2 and XIGrabKeycode should provide the highest priority grabbing under Xorg so that even applications that do server-wide grabs (e.g. games) will be bypassed.
XTest was meant for automated UI testing but can be used for all sorts of automated behaviors.
For the first part i wrote a simple program[2] years a go that uses xkill to kill the toplevel window with Ctrl+Alt+K (mainly for games that grab the input and hang) which can be used as a quick example. I haven't tried to use XTestFakeKeyEvent but there seems to be a lot of code out there which can be used as an example, e.g. this one[2] (see the send_key function near the top).
[0] https://linux.die.net/man/3/xigrabkeycode
[1] https://linux.die.net/man/3/xtestfakekeyevent
[2] http://runtimeterror.com/tools/xkeyller/
[3] http://git.yoctoproject.org/cgit.cgi/matchbox-history/plain/...
At the simplest level, it re-maps ^H to the left cursor arrow, ^N to PageDown, etc.
But it gets more complicated: ^D maps to seven down cursor arrows (i.e. it moves the cursor down seven lines), ^U in the opposite direction. ^C usually (more details below) maps to ^Left (i.e. go to the beginning of the word), Shift-^Right (select to end of word), and ^C (copy selected text). (Notice the final ^C does not cause recursion!)
^A once goes to the beginning of the line, ^A twice goes to top of screen (I forget the exact keystrokes it emits, but this works with most apps), and ^A thrice goes to the beginning of the file. Analogously for ^E, but end.
Finally, it has two modes. In the normal mode, all the cursor control keys do their normal cursor movement thing. But type ^Q, and the cursor keys are now in select mode: ^H outputs Shift-Left, i.e. selects the character to the left, etc. Drop out of select mode with ^C (copy selection--different from what I described above!), ^X (cut selection), or ^Q again (do nothing with the selection).
I'd love to be able to reproduce this kind of behavior in Linux. I'm sure it's possible, but I don't know enough about keyboard re-mapping, or keyboard drivers, to do it.