Creates a new key command object that matches the specified input.
SDKs
- iOS 7.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
+ (instancetype)keyCommandWithInput:(NSString *)input modifierFlags:(UIKey Modifier Flags)modifierFlags action:(SEL)action;
Parameters
input
The keys that the user must press. The string must contain one or more characters corresponding to the keys the user pressed. For a list of special characters that do not have a textual representation, see Input Strings for Special Keys.
modifierFlags
The bit mask of modifier keys that the user must press. You can use this parameter to specify which modifier keys (Command, Option, and so on) the user must also press. You may specify more than one modifier key. For a list of possible values, see
UIKey
.Modifier Flags action
The action method to execute on the responder object.
Return Value
A newly initialized key command object.
Discussion
After creating a key command object, you can:
Add it as a child of a
UIMenu
using the menu’sinit(title:
method.image: identifier: options: children:) Add it to a view controller using the
add
method of the view controller.Key Command: Override any responder class and return the key command directly from the responder’s
key
property.Commands