Fix keyboard event handling