Search code examples
cocoansbutton

How to setKeyEquivalent to Enter/Return key on NSButton?


I've tried [myButton setKeyEquivalent:@"\n"] but that didn't work. I feel like there should be some predefined constant for it that I'm just missing.

Thanks.


Solution

  • Try using "\r" instead of "\n" in this case.

    I believe [myButton setKeyEquivalent:@"\r"] should do what you are looking for.