If you fail to plan - You plan to fail
It starts when you go shopping. You need to change your habits a little. The produce section will be your friend now. Think buying enough produce for the week (or for the length of time that you go between one visit to the store to the next). Make sure to always have at home the keto friendly foods that you like.
I like to prepare for myself 5 salads for the week, this way I make sure that no matter what I will cook for the rest of the family, I will always have my salads waiting for me in the refrigerator as plan B'.
Always have a plan - when you go out with friends (think about which restaurant, check the menu beforehand so you can order without pressure).
Since any type of fatty meat is OK, most of the time, there is a meat choice in the menu, as well as vegetables. Ask to remove the potato or rice from your plate. If you go for a few days, take with you your favorite cream for the coffee. I even take it with me in a little container when we go visit friends, just in case they offer me coffee. If you go for longer time - take a few bouillon cubes with you, a few avocadoes, and if is a car trip, take also some hardboiled eggs. Think about your daily routine and make sure to stay on track.
Being out of the house for a long day of work or a short trip is a good opportunity to use those days for intermittent fasting - You are out of the house, away from the kitchen and coffee and tea is available anywhere.
For me planning is everything and it is what makes following the ketogenic diet easy. If I am invited for dinner, I will make sure to eat something at home before I go. I don't want to arrive to the place hungry and not to have any keto-friendly choice available for me.