A button that only works while you're holding the key. A ready-made fun circuit you can open in the TorchAnvil simulator.
A plain toggle flips every time you press the button — fine, but not very picky. What if the button should only respond when some other condition is true? Say, only while a keycard is inserted, or only when you're holding Shift. That's this circuit. The lamp only toggles when you press the button and the key lever is on. Press it without the key and nothing happens at all.
An AND gate is standing guard at the front door:
| Key | Press | AND (CLK) | Lamp |
|---|---|---|---|
| off | press | stays low | unchanged |
| on | press | rising edge | toggles |
| off | release | stays low | unchanged |
| on | release | stays low | unchanged |
The pattern is called a gated toggle, and it shows up everywhere you need "this action, but only under these conditions." Modifier-key shortcuts on your keyboard. Ignition interlocks on cars. Two-factor unlock on a safe. The authentication logic and the state change are kept in separate gates — one decides whether, the other does the what — and that clean split is the whole design lesson here.