How semi-permanent hair dye stays in place?

Semi-permanent hair dye washes off after several months. What mechanism(s) keep the dye in the hair? (I assume it's not primary chemical bonds, otherwise it would be permanent)

• One route to achive this by using reactive dyes, that upon contact with the keratine (that exhibits thiol-groups, $$\ce{R-SH}$$) indeed to form chemical bonds with the dye, the later -- for example -- decorated with sulfonic acids ($$\ce{R-SO3H}$$) or its salts. See, for example, patent US3415606 (A)