It's important to cook the onions over medium heat and stir them occasionally, checking on them every 5-10 minutes until they have completely caramelized and turned golden brown. If the onions appear to be getting too dark or sticking too much to the bottom of the pan, then simply reduce the heat a bit. You can also add a teaspoon or two of water.