MCPcopy
hub / github.com/nwutils/nw-sample-apps / handleKeyBinding

Function handleKeyBinding

mini-code-edit/cm/lib/codemirror.js:530–565  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

528 return true;
529 }
530 function handleKeyBinding(e) {
531 // Handle auto keymap transitions
532 var startMap = getKeyMap(options.keyMap), next = startMap.auto;
533 clearTimeout(maybeTransition);
534 if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
535 if (getKeyMap(options.keyMap) == startMap) {
536 options.keyMap = (next.call ? next.call(null, instance) : next);
537 }
538 }, 50);
539
540 var name = keyNames[e_prop(e, "keyCode")], handled = false;
541 if (name == null || e.altGraphKey) return false;
542 if (e_prop(e, "altKey")) name = "Alt-" + name;
543 if (e_prop(e, "ctrlKey")) name = "Ctrl-" + name;
544 if (e_prop(e, "metaKey")) name = "Cmd-" + name;
545
546 var stopped = false;
547 function stop() { stopped = true; }
548
549 if (e_prop(e, "shiftKey")) {
550 handled = lookupKey("Shift-" + name, options.extraKeys, options.keyMap,
551 function(b) {return doHandleBinding(b, true);}, stop)
552 || lookupKey(name, options.extraKeys, options.keyMap, function(b) {
553 if (typeof b == "string" && /^go[A-Z]/.test(b)) return doHandleBinding(b);
554 }, stop);
555 } else {
556 handled = lookupKey(name, options.extraKeys, options.keyMap, doHandleBinding, stop);
557 }
558 if (stopped) handled = false;
559 if (handled) {
560 e_preventDefault(e);
561 restartBlink();
562 if (ie) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
563 }
564 return handled;
565 }
566 function handleCharBinding(e, ch) {
567 var handled = lookupKey("'" + ch + "'", options.extraKeys,
568 options.keyMap, function(b) { return doHandleBinding(b, true); });

Callers 2

onKeyDownFunction · 0.85
onKeyPressFunction · 0.85

Calls 7

getKeyMapFunction · 0.85
isModifierKeyFunction · 0.85
e_propFunction · 0.85
lookupKeyFunction · 0.85
doHandleBindingFunction · 0.85
e_preventDefaultFunction · 0.85
restartBlinkFunction · 0.85

Tested by

no test coverage detected