You can see how this works in this BLOG POST
GarageKeypad allows me to control a self built 4x4 matrix keypad for access control to my garages.
Different codes allow for different devices to be controlled.
This firmware will allow communication via MQTT between the keypad and a central hub/server.