1 of 5

Haloalkanes react with KCN to form alkyl cyanides while AgCN forms isocyanides as the chief product?why please explain.

My question is Haloalkanes react with KCN to form alkyl cyanides as main product while AgCN forms isocyanides as the chief product?Why does this happen,please explain?