Is there a built-in way to listen for the Return key press? #226
Replies: 1 comment 1 reply
-
I didn't find one for my project. Nor was I able to catch the key event via .onKeyPress. I can suggest 2 options - presuming macOS- 1 - set up an event monitor - probably easier 2 - what I did - since my RichTextEditor is already in a NSHostingView, this opens up some of the underlying Appkit features, including a keyDown handler - which catches many keystrokes in general that can be lost to the quirks of swiftUI Focus voodoo. In the sample below, I specifically watch for Command+Option+Return. But I just checked, it also picks up an unmodified return key press typed into a RichTextEditor.
it's important to return false if you don't act upon the keypress, else it won't be passed on to RTE |
Beta Was this translation helpful? Give feedback.
-
Is there a built-in way to listen for the Return key press?
Beta Was this translation helpful? Give feedback.
All reactions