1. There is a field of characters
. . . . . . @. . . . . . .
- By pressing the keyboard key on a Mac, you need to move the
@
symbol - Everything happens in the Xcode console
How to respond to keyboard events?
1. There is a field of characters
. . . . . . @. . . . . . .
@
symbolHow to respond to keyboard events?
Any class that inherits from NSResponder responds to keyDown or keyUp
- (void)keyDown:(NSEvent *)theEvent { NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; unsigned short keyCode = [theEvent keyCode]; if([theEvent modifierFlags] & NSCommandKeyMask && keyCode == 36 /*Cmd+Enter*/) { [notificationCenter postNotificationName:@"cmdEnterKeyPressedNotification" object:nil]; return; } if(keyCode == 36 /*Enter*/) { [notificationCenter postNotificationName:@"enterKeyPressedNotification" object:nil]; return; } if(keyCode == 49 /*Space*/) { [notificationCenter postNotificationName:@"spaceKeyPressedNotification" object:nil]; return; } [super keyDown:theEvent];
}
Source: https://ru.stackoverflow.com/questions/511382/
All Articles