In a large mixing bowl, combine the cornmeal, all-purpose flour, chopped onion, baking powder, baking soda, salt, black pepper, and cayenne pepper (if using). Mix well.
In a separate bowl, whisk together the egg and buttermilk until well combined.
Pour the wet ingredients into the dry ingredients. Stir until just combined; do not overmix. The batter should be thick.
Heat vegetable oil in a deep fryer or deep pot over medium heat to 350°F (175°C).
Once the oil is hot, use a spoon or small ice cream scoop to drop spoonfuls of batter into the oil, being careful not to overcrowd the pot.
Fry the hush puppies for about 3-4 minutes, or until they turn golden brown, turning occasionally for even cooking.
Remove the fried hush puppies from the oil using a slotted spoon or tongs and drain on a baking sheet lined with paper towels.
Repeat until all the batter is fried. Serve warm.