Fix bug in how repeat and keypresses are handled.