this post was submitted on 05 Sep 2025
4 points (83.3% liked)

Swift

494 readers
1 users here now

This group focus on the content related to the development of Apple Eco-system software. So feel free to share and talk about, for example;

founded 2 years ago
MODERATORS
 

So I have a view that is focusable and has onKeyPress on it. I want to show a modal dialog when the user presses the delete key. However, it seems that the pressedKey.key for the delete key does not equal KeyEquivalent.delete value.

Example:

import SwiftUI

struct MyView: View {
    var body: some View {
        Rectangle()
            .frame(width: 100, height: 100)
            .focusable()
            .focusEffectDisabled()
            .onKeyPress { pressedKey in
                // Output: KeyEquivalent(character: "\u{7F}") == KeyEquivalent(character: "\u{08}")            
                print("\(pressedKey.key) == \(KeyEquivalent.delete)")
                return .handled
            }
    }
}

Am I missing something that is otherwise obvious?

you are viewing a single comment's thread
view the rest of the comments
[–] dohpaz42@lemmy.world 1 points 3 months ago

Can you do me a favor and block me already? If there’s anything worse than no responses, it’s your negativity.