Matrix Keypad - Optimisation

int k = kbValue(keyboardValue);

in plain English: kbValue() will do a lookup of keyboardValue (the parameter passed) and returns a value 0..16 to indicate the keypressed. This return value is assigned to the var k.

The names are a bit misleading here. Better names could be

  • int rawKeyPressed = analogread(A0);
  • int key = ConvertRawToKey(rawKeyPressed);
  • switch(key)

etc