There are locks that hold onto the key, I just watched a lockpickinglawyer vid yesterday about a Japanese warded lock that the key couldn't be removed until the lock was relocked again.
the video I mentioned if you're curious. He's always short and to the point with his content which is refreshing. https://www.youtube.com/watch?v=oSc9_Mv1Icg