Pressure-induced transition of the hydrogen bond in the ferroelectric compounds KH2P04 and KD2P04