MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / handleKeyBinding

Function handleKeyBinding

static/js/codemirror/codemirror.js:1882–1914  ·  view source on GitHub ↗
(cm, e)

Source from the content-addressed store, hash-verified

1880
1881 var maybeTransition;
1882 function handleKeyBinding(cm, e) {
1883 // Handle auto keymap transitions
1884 var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
1885 clearTimeout(maybeTransition);
1886 if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
1887 if (getKeyMap(cm.options.keyMap) == startMap)
1888 cm.options.keyMap = (next.call ? next.call(null, cm) : next);
1889 }, 50);
1890
1891 var name = keyName(e, true), handled = false;
1892 if (!name) return false;
1893 var keymaps = allKeyMaps(cm);
1894
1895 if (e.shiftKey) {
1896 // First try to resolve full name (including 'Shift-'). Failing
1897 // that, see if there is a cursor-motion command (starting with
1898 // 'go') bound to the keyname without 'Shift-'.
1899 handled = lookupKey("Shift-" + name, keymaps, function(b) {return doHandleBinding(cm, b, true);})
1900 || lookupKey(name, keymaps, function(b) {
1901 if (typeof b == "string" && /^go[A-Z]/.test(b)) return doHandleBinding(cm, b);
1902 });
1903 } else {
1904 handled = lookupKey(name, keymaps, function(b) { return doHandleBinding(cm, b); });
1905 }
1906 if (handled == "stop") handled = false;
1907
1908 if (handled) {
1909 e_preventDefault(e);
1910 restartBlink(cm);
1911 if (ie_lt9) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
1912 }
1913 return handled;
1914 }
1915
1916 function handleCharBinding(cm, e, ch) {
1917 var handled = lookupKey("'" + ch + "'", allKeyMaps(cm),

Callers 2

onKeyDownFunction · 0.85
onKeyPressFunction · 0.85

Calls 9

getKeyMapFunction · 0.85
isModifierKeyFunction · 0.85
keyNameFunction · 0.85
allKeyMapsFunction · 0.85
lookupKeyFunction · 0.85
doHandleBindingFunction · 0.85
e_preventDefaultFunction · 0.85
restartBlinkFunction · 0.85
testMethod · 0.45

Tested by

no test coverage detected