Using the following command to swap Esc and CapsLock keys:setxkbmap -option caps:swapescape
In versions below 22w16a this option would be registered by MC and for example pressing the CapsLock key would close menus. This is no longer the case, now pressing the CapsLock key does nothing and pressing the Esc key both closes menus and changes caps.
Probably caused by the LWJGL3 update from last snapshot.