How keys and locks work