Fixed keypress handling