tags:

views:

445

answers:

1

Below is the sample code.

- (void) keyDown: (NSEvent *) event
{
    NSString *chars = [event characters];
    unichar character = [chars characterAtIndex: 0];

    if (character == 27) {
        NSLog (@"ESCAPE!");
    }
}

Should I need to set any delegate in InterfaceBuilder or any kinda binding??

Help Appreciated...

+2  A: 

keyDown needs to be overridden in an NSView subclass whose object is set as first responder. The responder chain should pass down the event, but to be sure you get it, make sure that your object is first responder.

Naaff
Thanks a lot for these valuable inputs...