Added code to try and detect orientation with keyboard.