The key to perfectly caramelized onions is cooking them slowly over medium heat. Stir the onions regularly and adjust the heat if needed to prevent them from burning. Allow them to cook low and slow for the best flavor.