updated keycontroller logic