fix glitch in key handling