Matrix keyboard experiment principle, very detailed, there are examples