So this is the code that I have however it seems oversimplistic to me, which is probably why it isn't catching user keypresses as was my intent of this mini-project:
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
@interface keyObject : NSObject
- (void)mouseDown:(NSEvent *)theEvent;
@end
@implementation keyObject
- (void)mouseDown:(NSEvent *)theEvent {
NSLog(@"keypress detected!");
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"test");
keyObject * myObject = [[keyObject alloc] init];
}
while (1) {
// Waiting for event to trigger?
}
return 0;
}
I've read that it's possible to catch user-input without an NSView although maybe this would make it easier? I'd like to create a global hotkey via my own command line program.