Earlier, of course someone had to sit up. There's a Victorian tale of servants who went off gallivanting every night -- except one kitchen maid, forced, Cinderella-like, to wait at home and let them back in. And that's when keys existed. If you had to bolt the door, there's no way around it.
I wonder what magic would do.
Would it be as hard to make a key spell as to make a key? That took a lot of development.
And one might do things with words. Of course, that would let in anyone who knew or could guess the word. On the other hand, if you keyed it to your voice -- well, at the very least, I suspect that there would be a booming business in breaking such locks for the benefit of the heirs.
'cause you want a door to open to everyone it should as well as close out everyone it shouldn't. Even if a spell can work out intent, it might be interesting -- and if it can't, the possibilities are as interesting for magic as for mundane keys.