Yes, you can protect yourself from locking yourself out of your home. No, you don't leave your key under the door mat or under a rock, this is not a safe method.
What is safe is using a product that I sell in my online store. It under the Key Safe category.
All you do is purchase this and mount it to the inside door jam or garage door jam by your wireless garage door opener. It mounts with the supplied screws, but I don't use these. I use 2 to 2.5 inch long screws for added security. After successfully mounting the key safe, set your own personal code for it and your done. No electronics, all manual operation. So if you have kids or maybe have a house cleaner or other service people that need to come into your home, please use this product. Don't give your keys out. Not that you can't trust people, but rather keep your home safe and secure.