#143: Refactoring of keyboard navigation code. Working solution