The trick here is not only to avoid all obvious sources of carbohydrate (sweets, bread, spaghetti, rice, potatoes), but also to be careful with your protein intake. If you eat large amounts of meat, eggs and the like, the excess protein will be converted into glucose in your body. Large amounts of protein can also raise your insulin levels somewhat. This compromises optimal ketosis.
Be choosy about carbs. You can decide which ones you eat, and how much. Look for those that are low on the glycemic index (for instance, asparagus is lower on the glycemic index than a potato) or lower in carbs per serving than others. Whole grains are better choices than processed items, because processing removes key nutrients such as fiber, iron, and B vitamins. They may be added back, such as in “enriched” bread.