Lock your Chest to protect your Items from other Players and Creepers.
If something breaks the Chest it will replace itself without any drop.
Even Hoppers underneath the Chest won't soak up your items. But be aware, if you put items with a hopper into a locked Chest , they will be lost.
The Crafting Table will show a Gold Nugget as result, but you will get the correct Item after you take it out.
[1.16+] If you haven't disabled the Tool Damage you can repair your Key with Gold Ingots. The get more Durability you can also enchant it with Unbreaking.
Show Messages in the Chat instead of above the Hotbar, to disable it again you need to execute the same Command except of the 1 replace with a 0.
To unlock a chest manually you need to stand on top of the chest ideally in the middle and execute this command. If the Chest is a double Chest you need to execute the command for both sides.
If you get a Green Shulker Box when you lock or unlock a chest you can use this two commands to fix it
[1.16+] Disable Tool Damage when locking a Chest, to enable it again you need to execute the same Command except of the 1 replace with a 0.