I have the following code that works well if you tap the escape key to cancel, but whether I use .defaultAction, or select .return, modifiers: [] neither work. I also have multiple alerts I am trying to use the return key for whenever they appear. Does anyone know how I can accomplish setting the action to be taken on an alert to the return? I also wonder does having it be a destructive action matter whether a keyboardShortcut modifier works or not? Thanks for any help. You rock!
.alert("Alert User", isPresented: $isButtonTapped) {
Button("No", role: .cancel) {
isButtonTapped = false
}
.keyboardShortcut(.escape, modifiers: [])
Button("Yes", role: .destructive) {
model.reset()
isButtonTapped = false
}
.keyboardShortcut(.defaultAction)
} message: {
Text("Are you sure you want to do this? This action resets everything.")
}