"Is it possible to be anything to do with the battery as that doesn't charge anymore? "
Absolutely not, this is very specific to your keyboard scanning circuitry.
You can run any laptop on battery only, or with no battery in it, on charger only, and the keyboard scanning circuitry, which IS the issue, would never know or care.
If it were mine, I would expose the Motherboard, and see if there is a particular IC that the Keyboard cable goes to, and if there is one, replace that.
BUT FIRST I would look VERY CAREFULLY at the keyboard cable connector, and very gently clean those contacts with maybe 600 grit sand paper.
Then blow out that connector with canned wind. (you know what I mean). And make sure the soldering on the connector has no corrosion, and is just clean and shiny.
Better yet, just replace the damned connector, do a deep dive search on that connector, and get one and replace it, or find someone who can.
It's either going to be the scanning circuitry hardware, (IC) or the connector. Assuming you replaced the keyboard with a new one as you said.
BUT HEY,,,,,,,,, IF ALL ELSE IS LOST, OR YOU WANT NONE OF THE ABOVE. LAST DITCH SURE FIX WOULD BE PLUG IN A WIRELESS KEYBOARD USB ADAPTER,
AND USE IT'S ASSOCIATED WIRELESS KEYBOARD. OTHERWISE IT'S A MOTHERBOARD REPLACEMENT.