In case anybody would like to use this with ZHA instead of Zigbee2Mqtt, I created a repo with blueprints, sample scripts and dashboard to make it easy to configure user codes.
By default 4 user codes are created as well as 2 one-time user codes. The one-time user codes get reset to 0000 (disabled) after each use.
Just enter a 4-digit code on the keypad and let the scripts assigned in the automation do whatever action you wish.
More details can be found here: HA Zigbee Keypad
The look and feel of the dashboard was inspired by Keymaster integration: