Move key handling into controller