modified keyscan code