Keycodes don't change with the keyboard layout. For example, the key labeled Y on a QWERTY keyboard will result in the same evdev keycode (KEY_Y
in input-event-codes.h
) as the key labeled Z on a QWERTZ keyboard.
X11 reserves keycodes 0-7, and as such it offsets Linux/evdev keycodes by 8 values to make space for them. Wayland doesn't do this12, and usually compositors just pass the keycodes from libinput/evdev as-is.
xkbcommon is provided with a keymap, and it's used to get modifier states from keycodes and to convert from X11 keycodes (offset by 8 from Linux/evdev keycodes; termed as "Raw keycodes" in xkbcommon) to keysyms.