Each buttons press is detected by a rising edge detector, and each button press is decoded into a binary code. That binary code is stored in a shift-register which is continuously checked against a reference value ('the padlock code').
Connect a clock generator to the clock input, connect all four buttons with a debounce circuit - the buttons should act as active high.
Four push buttons, cabled as active high with hardware debounce circuitry.

| # | Input | Output |
|---|---|---|
| 0 | clock | |
| 1 | Button A | |
| 2 | Button B | |
| 3 | Button C | |
| 4 | Button D | |
| 5 | ||
| 6 | Button press detected | |
| 7 | Code valid |