fix keyboard event handling