One Logo Pool Ball
SwiftUI · IOS API REFERENCE

KeyboardShortcut

struct · iOS 14.0+ · SDK 27.1

struct KeyboardShortcut

Keyboard shortcuts describe combinations of keys on a keyboard that the user can press in order to activate a button or toggle.

Members (10)

get · iOS 14.0+

cancelAction

TypeScript
static get cancelAction(): KeyboardShortcut
Swift declaration
static let cancelAction: KeyboardShortcut

The standard keyboard shortcut for cancelling the in-progress action or dismissing a prompt, consisting of the Escape (⎋) key and no modifiers.

get · iOS 15.0+

localization

TypeScript
get localization(): KeyboardShortcut_Localization
Swift declaration
var localization: KeyboardShortcut.Localization

The localization strategy to apply to this shortcut.

set · iOS 15.0+

localization

TypeScript
set localization(value: KeyboardShortcut_Localization)
Swift declaration
var localization: KeyboardShortcut.Localization

The localization strategy to apply to this shortcut.

get · iOS 14.0+

defaultAction

TypeScript
static get defaultAction(): KeyboardShortcut
Swift declaration
static let defaultAction: KeyboardShortcut

The standard keyboard shortcut for the default button, consisting of the Return (↩) key and no modifiers. On macOS, the default button is designated with special coloration. If more than one control is assigned this shortcut, only the first one is emphasized.

get · iOS 14.0+

key

TypeScript
get key(): KeyEquivalent
Swift declaration
var key: KeyEquivalent

The key equivalent that the user presses in conjunction with any specified modifier keys to activate the shortcut.

set · iOS 14.0+

key

TypeScript
set key(value: KeyEquivalent)
Swift declaration
var key: KeyEquivalent

The key equivalent that the user presses in conjunction with any specified modifier keys to activate the shortcut.

get · iOS 14.0+

modifiers

TypeScript
get modifiers(): _SwiftUICore_EventModifiers
Swift declaration
var modifiers: EventModifiers

The modifier keys that the user presses in conjunction with a key equivalent to activate the shortcut.

set · iOS 14.0+

modifiers

TypeScript
set modifiers(value: _SwiftUICore_EventModifiers)
Swift declaration
var modifiers: EventModifiers

The modifier keys that the user presses in conjunction with a key equivalent to activate the shortcut.

init · iOS 15.0+

init

TypeScript
static initModifiersLocalization(key: KeyEquivalent, modifiers: _SwiftUICore_EventModifiers, localization: KeyboardShortcut_Localization): KeyboardShortcut
Swift declaration
init(_ key: KeyEquivalent, modifiers: EventModifiers = .command, localization: KeyboardShortcut.Localization)

Creates a new keyboard shortcut with the given key equivalent and set of modifier keys. Use the `localization` parameter to specify a localization strategy for this shortcut.

init · iOS 14.0+

init

TypeScript
static initModifiers(key: KeyEquivalent, modifiers?: _SwiftUICore_EventModifiers): KeyboardShortcut
Swift declaration
init(_ key: KeyEquivalent, modifiers: EventModifiers = .command)

Creates a new keyboard shortcut with the given key equivalent and set of modifier keys. The localization configuration defaults to ``KeyboardShortcut/Localization-swift.struct/automatic``.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →