Class

UIKeyCommand

The UIKeyCommand class specifies a key presses performed on a hardware keyboard and the resulting action that should take place. Hardware keyboards allow a user to hold down the Control, Option, Command, or other modifier key and press a key in combination to initiate commands such as cut, copy, or paste. You can use instances of this class to define custom command sequences that your app recognizes and then provide an appropriate response.

Overview

To use this class, you create instances and associate them with your app’s responder objects. Each responder has a keyCommands property that you can redefine and use to return the key command objects that responder supports. Key command sequences are generated only for devices with an attached hardware keyboard.

The system always has the first opportunity to handle key commands. Key commands that map to known system events (such as cut, copy and paste) are automatically routed to the appropriate responder methods. For other key commands, UIKit looks for an object in the responder chain with a key command object that matches the pressed keys. If it finds such an object, it then walks the responder chain looking for the first object that implements the corresponding action method and calls the first one it finds.

Symbols

Creating a Key Command Object

init(input: String, modifierFlags: UIKeyModifierFlags, action: Selector, discoverabilityTitle: String)

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

init(input: String, modifierFlags: UIKeyModifierFlags, action: Selector)

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

Getting the Key Command Attributes

var input: String

The string of characters corresponding to the keys that must be pressed to match this key command.

var modifierFlags: UIKeyModifierFlags

The bit mask of modifier flags that must be pressed to match this key command.

var discoverabilityTitle: String?

The title to display to the user.

Constants

UIKeyModifierFlags

These constants indicate which modifier keys are pressed.

Input Strings for Special Keys

These constants represent the text input strings that correspond to special non visible keys.

Relationships

Inherits From