Skip to content

Instantly share code, notes, and snippets.

@anuk79
Last active May 14, 2020 04:49
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 anuk79/78c1a7520a1649779b91c8663155d84f to your computer and use it in GitHub Desktop.
Save anuk79/78c1a7520a1649779b91c8663155d84f to your computer and use it in GitHub Desktop.
document.addEventListener('keyup', (event) => {
switch (event.keyCode) {
// escape
case 27:
// code to exit current component
break;
// enter || spacebar
case 13 || 32:
// submit or some action
break;
// left arrow
case 37:
// move back / previous
break;
// right arrow
case 39:
// move forward
break;
// up arrow
case 38:
// move up
break;
// down arrow
case 40:
// move down
break;
}
}
// reference - https://benrobertson.io/accessibility/javascript-accessibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment