Hopefully something along these lines gets incorporated into visionOS before launch (or as a v2 fast-follow). Typing against a floating keyboard in thin air is not ideal!
I'm not sure where mine got to, but the Tap Strap worked okay typing against my leg. https://www.tapwithus.com/product/tap-strap-2/ I don't recall whether I had version 1 or 2, and I have no idea how the XR behaves.