Skip to content

Instantly share code, notes, and snippets.

@bfgeek
Last active May 23, 2016 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfgeek/dbec129142c926c17dda6742c644302f to your computer and use it in GitHub Desktop.
Save bfgeek/dbec129142c926c17dda6742c644302f to your computer and use it in GitHub Desktop.
css-ui nav
window.addEventListener("keydown", (evt) => {
let prop = '--nav-';
switch (evt.key) {
case "ArrowDown":
prop += 'down';
break;
case "ArrowUp":
prop += 'up';
break;
case "ArrowLeft":
prop += 'left';
break;
case "ArrowRight":
prop += 'right';
break;
default:
return;
}
const id = getComputedStyleMap(evt.target).get(prop).cssText;
const focusEl = document.getElementById(id);
focusEl.focus();
evt.preventDefault();
}, true);
@bfgeek
Copy link
Author

bfgeek commented May 23, 2016

Probably correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment