There appears to be 2 issues. One is software, the other hardware. I suppose some people may have both.
I have a replacement keyboard, which has pretty much fixed the problem. However, I still have fairly frequent times when it is not connected correctly (much less than before). To reconnect, I rock the iPad forwards, then back to its normal position. I find that the on-screen software keyboard disappears and I can type normally.
Witht the replacement keyboard, the loss of connection mostly happens when I am sitting with the iPad/Keyboard on my knee. If I have it on a hard surface (table) then it is usually ok and if it isn’t, then one rock forward/back will fix it.
On my first keyboard, I noticed that the 3 connecting pins were not level. When I got the replacement, I noticed that these pins were level. They appear to have shifted a bit now, so that they are very very slightly uneven. (I‘m talking fractions).