This is something I never thought about. So key codes are based on the physical location of the key on a standard layout/qwerty, and changing your layout will cause the key value to change but not the code?
Keysyms don't necessarily strictly match "key location"; keyboards are allowed to output whatever codes they want for whatever key they want (see e.g. QMK firmware; often used in custom keyboards to do complex conditional key remapping), but they're in practice relatively consistent between common keys on most keyboards, and consistent on the same keyboard even if you switch keyboard layouts in software, unless you have some custom keyboard firmware which functionality is stateful.