             var kbRect = (info[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
             kbRect = view.convert(kbRect, from: view.window)
             let height = view.bounds.size.height - kbRect.origin.y
-            if let constraint = keyboardHeight {
+            if let constraint = keyboardHeight() {
                 if constraint.constant != height {
                     print("Bottom layout constant = \(height)")
                     keyboardHeightDidUpdate(height)


extension KeyboardResponder where Self: UIViewController {

    var keyboardHeight: NSLayoutConstraint? {
        return nil
    }


import UIKit

public protocol KeyboardResponder {
    func keyboardHeight() -> NSLayoutConstraint?
    func keyboardWillChange(_ notif: Notification)
    func keyboardHeightDidUpdate(_ height: CGFloat)
}
