Fix keyboard events in raw mode