I added support for X Windows bindings to Plan 9 from User Space's keyboard(7) a few months ago: http://swtch.com/plan9port/man/man7/keyboard.html
I just found out that you can write similarly complex keyboard input rules for OS X. For example download http://quinon.com/files/keylayouts/AltLatin.zip and look at AltLatin/AltLatin.bundle/Contents/Resources/AltLatin.keylayout. Maybe someone will be motivated to add support to mklatinkbd so it can generate one of these! Russ