fixed bug with key events