So I have had another look at trying to rectify this design whilst still using the KY-040 board without de-boarding the rotary encoder as per the OP's solution. Here's what I came up with and have proven it works in testing.
As a new user I was unable to add all the images and links so here's a link to the folder with them all.
KY-040 Keyboard Matrix Solution
The board circuit is big enough to be able to work with, so firstly de-solder the pin as best as possible, use a solder sucker is best.
Solder Sucker Link
see KY-040 Circuit Map in folder
In the circuit image you can isolate the earthed pin, do this by carefully using a scalpel or small sharp blade to cut an area around the pin, careful not to impact any other tracks. once you have cut lines down to the phenollic (the base on which the copper tracks lay) then carefully use the blade to push under the copper track towards the port pin, always working away from the other tracks, once all the copper is removed you need to solder in a new wire on the pin.
see KY-040 KY-040-Solution-9 in folder
I found the best way was to push the wire through the hole and to solder on to the leg on the top side of the board.
See KY-040-Solution-4 in folder
Using the Keyboard Matrix sketch you wont need to use the +5V, you will only need the pins in the image below. Hope this helps anyone in the same situation.
See KY-040-Solution-7 in folder