Contents

Input events

Respond to input from a hardware device, like a keyboard or a Touch Bar.

Overview

SwiftUI provides view modifiers that enable your app to listen for and react to various kinds of user input. For example, you can create keyboard shortcuts, respond to a form submission, or take input from the digital crown of an Apple Watch.

[Image]

For design guidance, see Inputs in the Human Interface Guidelines.

Topics

Responding to keyboard input

Creating keyboard shortcuts

Responding to modifier keys

Responding to hover events

Modifying pointer appearance

Changing view appearance for hover events

Responding to submission events

Labeling a submission event

Responding to commands

Controlling hit testing

Interacting with the Digital Crown

Managing Touch Bar input

Responding to capture events

See Also

Event handling