MCPcopy Create free account
hub / github.com/codename-co/stack / queryActiveBindings

Function queryActiveBindings

hub/astray/keyboard.js:130–164  ·  view source on GitHub ↗

* Generates an array of active key bindings

()

Source from the content-addressed store, hash-verified

128 * Generates an array of active key bindings
129 */
130 function queryActiveBindings() {
131 var bindingStack = [];
132
133 //loop through the key binding groups by number of keys.
134 for(var keyCount = keyBindingGroups.length; keyCount > -1; keyCount -= 1) {
135 if(keyBindingGroups[keyCount]) {
136 var KeyBindingGroup = keyBindingGroups[keyCount];
137
138 //loop through the key bindings of the same key length.
139 for(var bindingIndex = 0; bindingIndex < KeyBindingGroup.length; bindingIndex += 1) {
140 var binding = KeyBindingGroup[bindingIndex],
141
142 //assume the binding is active till a required key is found to be unsatisfied
143 keyBindingActive = true;
144
145 //loop through each key required by the binding.
146 for(var keyIndex = 0; keyIndex < binding.keys.length; keyIndex += 1) {
147 var key = binding.keys[keyIndex];
148
149 //if the current key is not in the active keys array the mark the binding as inactive
150 if(activeKeys.indexOf(key) < 0) {
151 keyBindingActive = false;
152 }
153 }
154
155 //if the key combo is still active then push it into the binding stack
156 if(keyBindingActive) {
157 bindingStack.push(binding);
158 }
159 }
160 }
161 }
162
163 return bindingStack;
164 }
165
166 /**
167 * Collects active keys, sets active binds and fires on key down callbacks

Callers 2

executeActiveKeyBindingsFunction · 0.85
pruneActiveKeyBindingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected