Oh , cool!
The keys a,z,e,r,t,y give you 24-29?
On my keyboard, the numbers 24-29 are produced by the keys q,w,e,r,t,y. So indeed you were right. Interestingly, if games were using keycodes for wasd movement you could have played them on your azerty keyboard without any problem.
One more thing we should check, if you ask X to convert the code 24 to keysym what would be its output? 'q' or 'a'? On qwerty it is converted to 113 which is 'q'.
So how do we go on from here? We have to think some more.
There is one thing that should not be forgotten. For a given physical keyboard layout, there should be a way to get the code of a specific key regardless of the current language or modifier keys. I am talking about the event.key.code. The current situation where shift+1 is translated to '0' can be improved if we use keycodes for this purpose.
I have to think a bit. Maybe there is a good solution for everything including different physical layouts although I doubt it because if it was simple why games don't implement it.