Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@digitalconceptvisuals
Created July 30, 2020 18:11
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 digitalconceptvisuals/4eb0df3991030b4124dbabc49569a98f to your computer and use it in GitHub Desktop.
Save digitalconceptvisuals/4eb0df3991030b4124dbabc49569a98f to your computer and use it in GitHub Desktop.
// Convert switch-case to
// dynamically loadable map
function keyName(keyCode) {
// Load the keymap from a file
const keyMap = require("./keymap.json");
// Now look up keyCode in map
return keyMap[keyCode];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment