问题
When I press ^
or `
and then a
or e
I get only a
or e
instead of â
or é
.
This is my code:
- (void) keyDown:(NSEvent*)event
{
NSString* str = [event characters];
}
How do I solve this?
回答1:
keyDown: only gives the characters for the key you currently are pressing down. Characters that take more than one keystroke show up as a separate keyDown: call for each keystroke. If you want to see typed characters instead of individual keypresses, override -insertText: instead.
来源:https://stackoverflow.com/questions/7100131/how-to-get-characters-with-accent-from-nsevent