I’d use «кепка» for 'cap'.
For me, шапка is usually softer, doesn’t have a rigid form and is often knited. Шапка is usually only worn in winter:
Капелюх has a rigid cylindrical form and brims. Капелюх can be worn in all times of the year (a sombrero is a form of капелюх which is worn in summer). Here's an example:
And кепка, which comes from the English ‘cap’, has a relatively rigid half-spherical form and can have a visor, and is usually only worn in summer: Here’s an example: