Same issue here. I went to Apple Store twice. First time, Tech couldn't reproduce problems at all. This morning, Keyboard stop working all together. I tried cold reboots etc and nothing work. So I just went to the Apple store again.
Tech want to complete wipe my iPad Pro and reinstall to OS to eliminate software issue. I request that we tried a different keyboard with my iPad. The other keyboard worked fine. While mine is very intermittence. It works a bit and stop working.
Tech is still not too convinced. He still want to do a full OS wipe.
But after some more convincing, he did do retail swap for me on the spot. I'm typing on the new keyboard right now and so far so good.
Big thumb up for Apple support.
One thing that I learn from this experience that I should also try clean OS wipe to eliminate software issue angle.
Athough from what I've seen so far, it appears to be a hardware problem. It looks like the handshake/authentication failed with my old keyboard. Perhaps the chip inside the old keyboard or connection have some intermittence problem.