I'm not sure whether have pictured this correctly Manie.
Take a look at this below.
If you strobe the blues, and scan the yellows you can work out which button has been pressed.
(For the sake of argument assume when you press a button it connects blue track to yellow).
By strobing I mean (ideally) connect the blues to tri-stated pins. Then, one at a time, make them an output, set high, (the other blues as inputs). Then read the yellow channels connected to pins in input mode. Many people play safe and use protection resistors and you really need pull-up/down resistors for the yellows.
Clever people may take adavantage of soft pullups and invert the outputs to blues.
Example, assuming pulldowns on yellows:-
If Blue1 only is high and you press top left key, then yellow 1 goes high, yellow 2&3 low.
As you have set only Blue1 high you know that it can't be the middle-left or bottom-left button that has been pressed.
Bingo, you know its top left.
Then, your programme would (ideally) tristate Blue1 as input, then set Blue2 to Output and set it high.
If top-left button were still pressed then nothing is on Yellows 1-3.
So, your programme 'strobes' the blue ones one-at-a-time and 'scans' the yellow ones.
Because YOUR programme knows which Blue line is high then it will know which button has been pressed.