fixed the buggy keyboard handler