You replaced the battery yourself?
Are you referring to the Surface Touch or Type Cover keyboard or a Bluetooth keyboard?
That might make a difference in what connection or connections may have problems.
If you replaced the battery yourself or someone else did Id guess that one or more connections weren't reconnected or became damaged or not fully connected. That's what id assume if I had done it.
How about a USB keyboard & mouse, does that work?