MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / handleKeyBinding

Function handleKeyBinding

lib/web/CodeMirror/src/edit/key_events.js:83–99  ·  view source on GitHub ↗
(cm, e)

Source from the content-addressed store, hash-verified

81
82// Handle a key from the keydown event.
83function handleKeyBinding(cm, e) {
84 let name = keyName(e, true)
85 if (!name) return false
86
87 if (e.shiftKey && !cm.state.keySeq) {
88 // First try to resolve full name (including 'Shift-'). Failing
89 // that, see if there is a cursor-motion command (starting with
90 // 'go') bound to the keyname without 'Shift-'.
91 return dispatchKey(cm, "Shift-" + name, e, b => doHandleBinding(cm, b, true))
92 || dispatchKey(cm, name, e, b => {
93 if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
94 return doHandleBinding(cm, b)
95 })
96 } else {
97 return dispatchKey(cm, name, e, b => doHandleBinding(cm, b))
98 }
99}
100
101// Handle a key from the keypress event
102function handleCharBinding(cm, e, ch) {

Callers 2

onKeyDownFunction · 0.70
onKeyPressFunction · 0.70

Calls 4

keyNameFunction · 0.90
dispatchKeyFunction · 0.70
doHandleBindingFunction · 0.70
testMethod · 0.45

Tested by

no test coverage detected