fix keyboard dismissal and firstResponder bugs. close #640. close #510.