The chemical reactions and pathways involving keratan sulfate, a glycosaminoglycan with repeat units consisting of beta-1,4-linked D-galactopyranosyl-beta-(1,4)-N-acetyl-D-glucosamine 6-sulfate and with variable amounts of fucose, sialic acid and mannose units; keratan sulfate chains are covalently linked by a glycosidic attachment through the trisaccharide galactosyl-galactosyl-xylose to peptidyl-threonine or serine residues.