Comparison of energy losses of electrons with optical properties of KCl and KBr