You can use NSCharacterSet
:
- (void)keyDown:(NSEvent *)theEvent
{
NSString * const character = [theEvent charactersIgnoringModifiers];
if ([character length] > 0)
{
unichar c = [character characterAtIndex:0];
NSCharacterSet *letters = [NSCharacterSet letterCharacterSet];
if ([letters characterIsMember:c])
{
NSLog(@"that's a letter!");
}
}
}
If you are calling this code frequently it might pay to store letters
as an instance variable.