I implemented this function to detect touches outside keyboard and hide the keyboard 

```
extension UIViewController {
    func hideKeyboardWhenTappedAround() {
        let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard))
        tap.cancelsTouchesInView = false
        view.addGestureRecognizer(tap)
    }

```

but how can I do callback when a user touches outside the keyboard? I want another action to happen. I don't want only the keyboard to be hidden.I want to do other function including hiding keyboard everytime the keyboard is hidden I wa=ish to have more actions.