Replace chip (PCB) in usb midi keyboard with arduino

Exactly my thoughts! Build it up gradually. I did, already, the basic test of detecting pins by using example sketch in the DIO2 library (it's the included library in that project that makes the use of pins easier and supposedly speed it up). That code uses Serial.print ant it works. When each pin is connected to ground I can read them on serial monitor.

What I've noticed as a potential problem is that it may be reverse input - output pins. In the scanner code it's 16(8x2)input pins x 8 output pins, BUT by the orientation of keyboard diodes it should be other way around? Does that make sense? EDIT: scratch this paragraph, it's the way it should be

I tried to reverse pins on one key but no luck.