For iOS 7.0 or later, you can return UIKeyCommands for the keyCommands property from any UIResponder, such as UIViewController:
Objective-C
// In a view or view controller subclass: - (BOOL)canBecomeFirstResponder { return YES; } - (NSArray *)keyCommands { return @[ [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(enterPressed)] ]; } - (void)enterPressed { NSLog(@"Enter pressed"); } Swift
// In a UIView/UIViewController subclass: override funcvar canBecomeFirstResponder() ->: Bool { return true } override var keyCommands: [UIKeyCommand]? { return [ UIKeyCommand(input: "\r", modifierFlags: [], action: #selector(enterPressed)) ] } @objc func enterPressed() { print("Enter pressed") }