We present a study of cyanoacetylene (HC3N) and cyanodiacetylene (HC5N) in Orion KL, through observations from two line surveys performed with the IRAM 30m telescope and the HIFI instrument on board the Herschel telescope. The frequency ranges covered are 80-280 GHz and 480-1906 GHz. We model the observed lines of HC3N, HC5N, their isotopologues (including DC3N), and vibrational modes, using a non-LTE radiative transfer code. To investigate the chemical origin of HC3N and DC3N in Orion KL, we use a time-dependent chemical model. We detect 40 lines of the ground state of HC3N and 68 lines of its 13C isotopologues. We also detect 297 lines of six vibrational modes of this molecule (nu_7, 2nu_7, 3nu_7, nu_6, nu_5, and nu_6+nu_7) and 35 rotational lines of the ground state of HC5N. We report the first tentative detection of DC3N in a giant molecular cloud with a DC3N/HC3N abundance ratio of 0.015. We provide column densities and isotopic and molecular abundances. We also perform a 2x2 map around Orion IRc2 and we present maps of HC3N lines and maps of lines of the HC3N vibrational modes nu_6 and nu_7. In addition, a comparison of our results for HC3N with those in other clouds allows us to derive correlations between the column density, the FWHM, the mass, and the luminosity of the clouds. The high column densities of HC3N obtained in the hot core, make this molecule an excellent tracer of hot and dense gas. In addition, the large frequency range covered reveals the need to consider a temperature and density gradient in the hot core in order to obtain better line fits. The high D/H ratio (comparable to that obtained in cold clouds) that we derive suggests a deuterium enrichment. Our chemical models indicate that the possible deuterated HC3N present in Orion KL is formed during the gas-phase. This fact provides new hints concerning the processes leading to deuteration.