I am a veteran of several dozen mame cabinets and I am very well versed in repairing real games, soldering and all that and I can promise you that keyboard and gamepad hacks are a mistake.
I have done it too multiple times. I have found that they are fragile, flaky, unreliable and far less functional than just buying an encoder. As often as not I ended up having to rip the whole mess out later and replace it with an encoder due to unforeseen issues or wires getting ripped out.
Now someone else will certainly chime in and say

I did it and it works and it is awesome and I saved $10

.
This isn't 1999 anymore, they have made products to do this properly for going on 10 years now. I am also cheap. I often finish entire projects with a budget less than what some people spend on light up buttons. But I am not so cheap that I can't spend $35 at the beginning of each project for a proper keyboard encoder.
Controller looks familiar, looks like the last one I wasted my time on, still have the circuit board in my desk as a matter of fact. It doesn't have a common ground, it requires very fine solder work that will easily break and to top it all off, if you have two of them they will randomly change positions each time you boot your computer. Of course all identical gamepads do that.