// amalyze row 1 
row1 = 1;
if (Px & COL_MASK)
{ // column active in this row
  key = row1_table[(Px & COL_MASK)] // translate column to key code
  return; // we done (multiple keys pressed not supported)
}
row1 = 0; // done with row 1
// amalyze row 2 
row2 = 1;
....
....