improved keyboard handling; better event handling