Substituting a matrix keyboard push button with transistor
This most likely is a matrix keyboard. This means there is no common potential you could refer to, but you need that to place transistors across more than one of the keys, and use a raspberry to control them.

I recommend YOU to use reed relays. They are small and they don't give you a headache.

There are ways to get around that limitation but they are not easy to implement and require to re-engineer the schematic first.