For redstone and command blocks, it’s over to Twilight Sparkle, who will tell you far more than you ever wanted to know about how to make a Place The Key control box! This is a large bedrock device at spawn that continually tests for the map’s win condition. They can also dole out punishments if the player’s done wrong, but be careful not to trigger attacks on the player unless you’re sure about it!
This device is what runs the map Nightmare Moon (first Applejinx Place The Key (PTK) map. It tests for the presence of the dragon egg, which must be placed by a player who has never killed anything.
(technically, you can still win the map if you’re in singleplayer or you have no pure and kill-less players left, by placing the egg and then getting out of Dodge. This is better than sensing ‘guilt’ and triggering a player-kill, because if the wrong player is too near the sensor they can ruin everything after a very long and epic LP-series, all at night)