Type Method

keyCommandWithInput:modifierFlags:action:

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

Declaration

+ (instancetype)keyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)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 UIKeyModifierFlags.

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:

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:discoverabilityTitle:

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

Deprecated
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.