Move keyboard handling into input module