     }
 
     setContextState(text: context, range: NSRange(newRange, in: context))
+  }
+  
+  @objc func clearSwallowFlag() {
+    self.swallowBackspaceTextChange = false
   }
 
   func insertText(_ keymanWeb: KeymanWebViewController, numCharsToDelete: Int, newText: String) {

  var landscapeConstraint: NSLayoutConstraint?

  private var keymanWeb: KeymanWebViewController

  open class var isPortrait: Bool {
    return UIScreen.main.bounds.width < UIScreen.main.bounds.height

        }
      }
    }
    
    self.swallowBackspaceTextChange = true
    // afterDelay 0.01 is not sufficient!  0.02 seems to be enough for an actual delay to register.
    perform(#selector(self.clearSwallowFlag), with: nil, afterDelay: 0.02)

    if !newText.isEmpty {
      textDocumentProxy.insertText(newText)
