MCPcopy Create free account
hub / github.com/TruthHun/BookStack / normalizeKeyName

Function normalizeKeyName

static/mergely/lib/codemirror.js:5810–5826  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

5808 // KEYMAP DISPATCH
5809
5810 function normalizeKeyName(name) {
5811 var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
5812 var alt, ctrl, shift, cmd;
5813 for (var i = 0; i < parts.length - 1; i++) {
5814 var mod = parts[i];
5815 if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
5816 else if (/^a(lt)?$/i.test(mod)) alt = true;
5817 else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
5818 else if (/^s(hift)$/i.test(mod)) shift = true;
5819 else throw new Error("Unrecognized modifier name: " + mod);
5820 }
5821 if (alt) name = "Alt-" + name;
5822 if (ctrl) name = "Ctrl-" + name;
5823 if (cmd) name = "Cmd-" + name;
5824 if (shift) name = "Shift-" + name;
5825 return name;
5826 }
5827
5828 // This is a kludge to keep keymaps mostly working as raw objects
5829 // (backwards compatibility) while at the same time support features

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected