Improved keyboardViewIsHidden calculation