Detect which key is pressed

2 Solutions Collect From Internet About “Detect which key is pressed”

Use the NSEvent methods keyCode, characters or charactersIgnoringModifiers.

- (void)keyUp:(NSEvent *)event {
    NSLog(@"Characters: %@", [event characters]);
    NSLog(@"KeyCode: %hu", [event keyCode]);
}

NSEvent has the keyCode method that returns exactly what you’re looking for.