> Huh? X only ever sends keycodes to clients, which are solely and 100% responsible for performing the translation to keysyms. It's possible to get a perfectly lossless translation with infinitely nested X servers, by just copying the keymaps and passing the keycodes straight through.
It can be slightly more complicated than that, given that the client system may not have the same mapping of key codes to physical keys (it may well not be running X at all), and that you are wanting to send the server key codes not symbols. On an X server with XKB and a reasonably PC-like keyboard you can get a pretty good idea of how the key codes and physical keys correspond, but that doesn't cover all systems by any means.