KeyEquivalent

Key equivalents consist of a letter, punctuation, or function key that can be combined with an optional set of modifier keys to specify a keyboard shortcut.

StructureiOS 14.0+macOS 11.0+tvOS 17.0+KeyEquivalent in SwiftUI

Declaration

React
type KeyEquivalent =
  | 'clear'
  | 'delete'
  | 'deleteForward'
  | 'downArrow'
  | 'end'
  | 'escape'
  | 'home'
  | 'leftArrow'
  | 'pageDown'
  | 'pageUp'
  | 'return'
  | 'rightArrow'
  | 'space'
  | 'tab'
  | 'upArrow';
Swift
struct KeyEquivalent

Pass a literal, or build one with SwiftUI.KeyEquivalent from import { SwiftUI } from 'swiftui-react-native'.

Type properties

Overview

Key equivalents are used to establish keyboard shortcuts to app functionality. Any key can be used as a key equivalent as long as pressing it produces a single character value. Key equivalents are typically initialized using a single-character string literal, with constants for unprintable or hard-to-type values.

The modifier keys necessary to type a key equivalent are factored in to the resulting keyboard shortcut. That is, a key equivalent whose raw value is the capitalized string "A" corresponds with the keyboard shortcut Command-Shift-A. The exact mapping may depend on the keyboard layout—for example, a key equivalent with the character value "}" produces a shortcut equivalent to Command-Shift-] on ANSI keyboards, but would produce a different shortcut for keyboard layouts where punctuation characters are in different locations.

From Apple’s SwiftUI documentation. Code samples there are Swift.

Used by

See also

More in Other values.