Is simple, e.g. a 2x2 matrix (lines and columns pins in controller board) handle 4 buttons.

Mean that every line is shared with 2 buttons and in same way every column is shared with 2 buttons.


upload image online free

The diodes, as explained in the link is for avoid keyboard ghosting with 3 or more buttons pressed simultaneous.

They made the current flow only in one direction.