Type Method

keyCommandWithInput:modifierFlags:action:discoverabilityTitle:

Creates and returns a new key command object that matches the specified input and has a title.

Declaration

+ (instancetype)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)modifierFlags action:(SEL)action discoverabilityTitle:(NSString *)discoverabilityTitle;

Parameters

input

The keys that must be pressed by the user. The string must contain one or more characters corresponding to the keys that were 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 must be pressed. You can use this parameter to specify which modifier keys (Command, Option, and so on) must also be pressed by the user. You may specify more than one modifier key. For a list of possible values, see UIKeyModifierFlags.

action

The action method to execute on the responder object.

discoverabilityTitle

A string that can be displayed to the user to explain the purpose of the key command.

Return Value

The initialized key command object.

Discussion

After creating a key command object, you can add it to a view controller using the addKeyCommand: method of the view controller. You can also override any responder class and return the key command directly from the responder’s keyCommands property.

See Also

Creating a Key Command Object

+ commandWithTitle:image:action:input:modifierFlags:propertyList:

Creates a key command that you can use as a menu element with a shortcut key, or a shortcut key only for a view controller.

+ commandWithTitle:image:action:input:modifierFlags:propertyList:alternates:

Creates a key command with alternatives that you can use as a menu element with a shortcut key, or a shortcut key only for a view controller.

+ keyCommandWithInput:modifierFlags:action:

Creates a new key command object that matches the specified input.

Adding Menus and Shortcuts to the Menu Bar and User Interface

Provide quick access to useful actions by adding menus and keyboard shortcuts to your Mac Catalyst app.