added key matrix reading