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

Function normalizeKeyName

static/editor.md/lib/codemirror/lib/codemirror.js:5608–5624  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

5606 // KEYMAP DISPATCH
5607
5608 function normalizeKeyName(name) {
5609 var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
5610 var alt, ctrl, shift, cmd;
5611 for (var i = 0; i < parts.length - 1; i++) {
5612 var mod = parts[i];
5613 if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
5614 else if (/^a(lt)?$/i.test(mod)) alt = true;
5615 else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
5616 else if (/^s(hift)$/i.test(mod)) shift = true;
5617 else throw new Error("Unrecognized modifier name: " + mod);
5618 }
5619 if (alt) name = "Alt-" + name;
5620 if (ctrl) name = "Ctrl-" + name;
5621 if (cmd) name = "Cmd-" + name;
5622 if (shift) name = "Shift-" + name;
5623 return name;
5624 }
5625
5626 // This is a kludge to keep keymaps mostly working as raw objects
5627 // (backwards compatibility) while at the same time support features

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected