FYI There are lots of alternatives to xcape (and even better ones because, in my experience, xcape is not compatible with VirtualBox or hot-plugging one's keyboard), e.g.:
https://gitlab.com/interception/linux/plugins/dual-function-... (currently using this – very powerful)
https://gitlab.com/at-home-modifier/at-home-modifier-evdev (used this for years – works extremely well)
Two more projects I've found that should work on Wayland: