This is what happends between an X Window Server and a client when a key is pressed: the X server starts with a keycode, which may be stored as a modifier if this keycode is specified to be a modifier. Regardless, the keycode goes to the client together with the set of modifiers that are currently down. The client can change the modifiers so that the key "a" acts like a "Shift".

There is also a separate mapping for translating keycode+modifier into a keysym. This mapping is stored in the server, which however does not use it. Clients usually retrieve this mapping for performing the translation.
No machine-readable source provided. Own work assumed (based on copyright claims).
No machine-readable author provided. Tizio assumed (based on copyright claims).