In a mixing bowl, combine the cornmeal, flour, baking powder, salt, sugar, black pepper, and cayenne pepper (if using). Stir well to blend all the dry ingredients.
In another bowl, whisk together the buttermilk and egg until well combined.
Pour the wet ingredients into the dry ingredients and mix until just combined. Do not overmix.
Fold in the chopped onion gently until evenly distributed in the batter.
Heat oil in a deep fryer or large pot over medium heat. The oil should be hot enough that a small drop of batter sizzles when added (around 365°F or 185°C).
Using a spoon or small ice cream scoop, drop spoonfuls of the batter into the hot oil, being careful not to overcrowd the pot.
Fry the hush puppies for about 3-4 minutes or until they are golden brown on all sides. Turn occasionally for even cooking.
Use a slotted spoon to remove the hush puppies from the oil and transfer them to a baking sheet lined with paper towels to drain excess oil.
Serve warm as a side dish or appetizer.