refactoring keyboard-nav.js