I use this to handle keyboard change and find out if my keyboard is selected
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification)) { _ in
if let currentInputMode = UIResponder.currentInputMode {
let language = currentInputMode.primaryLanguage
if language == "cls" {
isPresented = false
}
}
}
extension UIResponder {
static var currentInputMode: UITextInputMode? {
return UIApplication.shared.windows.first?.windowScene?.textInputMode
}
}