refactoring in camera code

Moved common code in keyboard methods to own method.