Capturing the enter key #160
Replies: 2 comments 2 replies
-
I haven't tried this, but is it possible to add native SwiftUI key press modifiers to the text editor for this purpose? |
Beta Was this translation helpful? Give feedback.
-
I too would like to intercept keypresses from a richTextEditor view. I'm failing to get key Down events. I added the .onKeyPress handler as discussed here: #36 (comment), but it is not called. ... unless watch for keyUP events. Then my onKeyPress handler is called, but at that point, it's too late and the character has already been inserted into the text. .onKeyPress(phases: .all) { key in
print("key pressed: \(key.debugDescription)")
return .ignored
}
output:
key pressed: KeyPress(.up, "a")
key pressed: KeyPress(.up, "b")
key pressed: KeyPress(.up, "c")
key pressed: KeyPress(.up, " ") My intent is to catch Tab key presses to tab between fields. In my usage, there is no role for a tab character in that text. Any hooks to intercept a keydown event before RichTextEditor? |
Beta Was this translation helpful? Give feedback.
-
Hi - new to this but hoping someone can help.
I would like to use the RichTextEditor to write a chat app. Therefore in my app, I want to capture certain key presses. Eg: Shift-Enter to allow me to move the curser to the new line and Enter to "send" the message, effectively run a prescribed bit of code. I've skimmed the documentation and can't seem to find anything, so asking here for help
Thanks
Beta Was this translation helpful? Give feedback.
All reactions