Photons and selective absorption

If the key fits the lock, then there is a result. Some colours trigger an effect: others do not. Photosynthesis, the colour of flowers, walls and bicycles are all determined by the interaction of photons with chemicals within the materials. As these are colour-dependent (and colour is related to frequency, and frequency to energy), photons can provide a neat account of the selective interaction of light and matter. A simplified band-gap approach.

But keys may still operate locks, even if the fit is not precise, so allow a looser fit. Materials are of varying complexity, and sometimes only sharply defined frequencies are selected, sometimes the fit can be more relaxed. Roughly, it depends on the complexity of interactions within the material.