Hi,
I'm new to Mac programming, so I hope this isn't obvious.
In short, I don't seem to be getting multiple key pressed events. I've created this snippet, which never fires an assert, and therefore never prints multiple keys. I get single key prints, though.
- (void)keyDown:(NSEvent *) theEvent {
NSString *characters = [theEvent characters];
assert([characters length]<2);
for (int i=0;i<[characters length];++i) {
NSLog(@"k=[%d]\n", [characters characterAtIndex:i]);
}
}
Does anyone know what I'm doing wrong? In case you're interested, I need multiple key presses for an OpenGL viewing application. Perhaps I am just completely off the mark for this sort of application.
Edit: After further research, I found this: http://www.cocoadev.com/index.pl?GameKeyBoardHandling This makes sense based on the discussion here, in that only the last key repeats. When a keyDown event is thrown, the down key is placed in set and removed on keyUp. This means the set has the complete set of currently held-down keys, avoiding the only-repeats-last-held issue. It's 'good enough', so I'm using this method now. It seems to work well, and because it uses the standard keyboard event system (rather than HID), there shouldn't be any compatibility issues.
Regards, Shane