The lattice dynamics of potassium dihydrogen phosphate (KDP) and its deuterated analog DKDP was studied via first-principles DFT calculations. A thorough assessment of the quality of a wide range of functionals supplemented with the approximate inclusion of quantum nuclear effects indicated that the non-local van der Waals functional vdW-DF [M. Dion et al, Phys. Rev. Lett. 92, 246401 (2004); J. Klimeš et al, Phys. Rev. B 83, 195131 (2011)] produces the best agreement with structural data for both compounds. This enabled the calculation of full phonon dispersions in the ferroelectric phase, and hence the phonon density of states and specific heat, in excellent agreement with experimental data. Phonon bands and especially modes at the Γ-point of the Brillouin zone were classified according to their vibrational pattern. This allowed for the assignment of stretching and bending modes of the hydrogen bonds. Internal modes involving the phosphate units were identified at lower frequencies, while the lowest-lying modes were those involving the K + ion. These assignments were used to interpret infrared and Raman spectra along the c-axis, and in the perpendicular plane. Phonon modes calculated at the Γ-point showed two types of instabilities. One was a normal mode polarized along the c-axis of the crystal, while the other corresponded to a twofold degenerate mode polarized in the perpendicular plane. The former gives rise to a spontaneous polarization in the ferroelectric phase at low temperatures by coupling to an optical K +-PO − 4 stretching mode, consistently with a significant off-diagonal Born effective charge on the hydrogen atoms. A mode describing the opposite rotation of neighboring PO4 tetrahedra was also found to couple strongly to the ferroelectric mode, as this modulates the O-O distance, which determines the barrier for proton transfer. The present study suggests that a minimal model to describe isotope effects in KDP should involve at least three fully-coupled vibrational modes.