A replica Kentucky pistol being fired several times, slowed so you can see the firing sequence.
When the trigger is pulled, a hammer with a small piece of flint attached snaps forward and strikes a piece of metal called a frizzen. This creates a shower of sparks that ignites a small pan of fine gunpowder. The flash travels through a small hole in the barrel and ignites the main charge. This causes a significant delay between when you pull the trigger and the projectile leaves the barrel, making accurate shooting quite challenging.
This is the origin of the phrase "a flash in the pan", to describe a short lived phenomenon.
Flintlocks were replaced prior to the Civil War with percussion cap weapons, which used an impact sensitive chemical to fire the charge. This eliminated the delay, and was much more reliable, especially in wet environments. Modern cartridge weapons came a few decades later.