Reestructure keyCodes method