Refactored keyboard related code into base view controller class.