Easy way to make a keyboard by GATES. For Bit 0 position find out which keys are 1 and which keys are 0. So 1 3 5 7 and 9 are 1 and 0 2 4 6 and 8 are 0. Now make a 5 inputs OR Gate and join 1 3 5 7 and 9 keys to the input and output to the first SR-FF Set point. Make another 5 inputs OR Gate and and join 0 2 4 6 and 8 keys to the input and output joined to first SR-FF Reset point. Likewise find out for other Bit position's 1 and 0 make required Gates and join.