 
 class KeyboardViewController: UIInputViewController {
     
+    let backspaceDelay: NSTimeInterval = 0.5
+    let backspaceRepeat: NSTimeInterval = 0.075
+    
     var keyboard: Keyboard
     var forwardingView: ForwardingView
     var layout: KeyboardLayout
     var heightConstraint: NSLayoutConstraint?
+    
+    var backspaceActive: Bool {
+        get {
+            return (backspaceDelayTimer != nil) || (backspaceRepeatTimer != nil)
+        }
+    }
+    var backspaceDelayTimer: NSTimer?
+    var backspaceRepeatTimer: NSTimer?
 
     // TODO: why does the app crash if this isn't here?
     convenience override init() {

        }
    }
    
    func backspacePressed(sender: KeyboardKey) {
        UIDevice.currentDevice().playInputClick()
        
        (self.textDocumentProxy as UITextDocumentProxy as UIKeyInput).deleteBackward()
    }
    

                case Key.KeyType.KeyboardChange:
                    keyView.addTarget(self, action: "advanceToNextInputMode", forControlEvents: .TouchUpInside)
                case Key.KeyType.Backspace:
                    let cancelEvents: UIControlEvents = UIControlEvents.TouchUpInside|UIControlEvents.TouchUpInside|UIControlEvents.TouchDragExit|UIControlEvents.TouchUpOutside|UIControlEvents.TouchCancel|UIControlEvents.TouchDragOutside
                    
                    keyView.addTarget(self, action: "backspaceDown:", forControlEvents: .TouchDown)
                    keyView.addTarget(self, action: "backspaceUp:", forControlEvents: cancelEvents)
                default:
                    break
                }
