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

Function unbindKey

hub/astray/keyboard.js:406–448  ·  view source on GitHub ↗

* Clears all key and key combo binds containing a given key or keys. * @param keys

(keys)

Source from the content-addressed store, hash-verified

404 * @param keys
405 */
406 function unbindKey(keys) {
407
408 if(keys === 'all') {
409 keyBindingGroups = [];
410 return;
411 }
412
413 keys = keys.replace(/\s/g, '').split(',');
414
415 //loop through the key binding groups.
416 for(var iKCL = keyBindingGroups.length; iKCL > -1; iKCL -= 1) {
417 if(keyBindingGroups[iKCL]) {
418 var KeyBindingGroup = keyBindingGroups[iKCL];
419
420 //loop through the key bindings.
421 for(var iB = 0; iB < KeyBindingGroup.length; iB += 1) {
422 var keyBinding = KeyBindingGroup[iB],
423 remove = false;
424
425 //loop through the current key binding keys.
426 for(var iKB = 0; iKB < keyBinding.keys.length; iKB += 1) {
427 var key = keyBinding.keys[iKB];
428
429 //loop through the keys to be removed
430 for(var iKR = 0; iKR < keys.length; iKR += 1) {
431 var keyToRemove = keys[iKR];
432 if(keyToRemove === key) {
433 remove = true;
434 break;
435 }
436 }
437 if(remove) { break; }
438 }
439 if(remove) {
440 keyBindingGroups[iKCL].splice(iB, 1); iB -= 1;
441 if(keyBindingGroups[iKCL].length < 1) {
442 delete keyBindingGroups[iKCL];
443 }
444 }
445 }
446 }
447 }
448 }
449
450 /**
451 * Gets an array of active keys

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected