The strong KI doublet near 7700{AA} and another doublet near 12500{AA} are studied in a sample of 324 M dwarfs using CARMENES spectra. For the optical doublet we use only the red line, since the blue line is often contaminated by telluric correction artefacts. Both doublets have a dominant photospheric component in inactive stars and can be used as tracers of effective temperature and gravity. For M dwarfs later than M5.0V the optical doublet lines develop an emission core. The line is often correlated to H{alpha} for stars with H{alpha} in emission and anticorrelated for stars with H{alpha} in absorption. The near-infrared doublet lines very rarely show correlation/anti-correlation to H{alpha}.