MCPcopy Create free account
hub / github.com/CodeboxIDE/codebox / _getKeyInfo

Function _getKeyInfo

client/vendors/mousetrap.js:737–778  ·  view source on GitHub ↗

* Gets info for a specific key combination * * @param {string} combination key combination ("command+s" or "a" or "*") * @param {string=} action * @returns {Object}

(combination, action)

Source from the content-addressed store, hash-verified

735 * @returns {Object}
736 */
737 function _getKeyInfo(combination, action) {
738 var keys,
739 key,
740 i,
741 modifiers = [];
742
743 // take the keys from this pattern and figure out what the actual
744 // pattern is all about
745 keys = _keysFromString(combination);
746
747 for (i = 0; i < keys.length; ++i) {
748 key = keys[i];
749
750 // normalize key names
751 if (_SPECIAL_ALIASES[key]) {
752 key = _SPECIAL_ALIASES[key];
753 }
754
755 // if this is not a keypress event then we should
756 // be smart about using shift keys
757 // this will only work for US keyboards however
758 if (action && action != 'keypress' && _SHIFT_MAP[key]) {
759 key = _SHIFT_MAP[key];
760 modifiers.push('shift');
761 }
762
763 // if this key is a modifier then add it to the list of modifiers
764 if (_isModifier(key)) {
765 modifiers.push(key);
766 }
767 }
768
769 // depending on what the key combination is
770 // we will try to pick the best event for it
771 action = _pickBestAction(key, modifiers, action);
772
773 return {
774 key: key,
775 modifiers: modifiers,
776 action: action
777 };
778 }
779
780 /**
781 * binds a single keyboard combination

Callers 2

_bindSequenceFunction · 0.85
_bindSingleFunction · 0.85

Calls 3

_keysFromStringFunction · 0.85
_isModifierFunction · 0.85
_pickBestActionFunction · 0.85

Tested by

no test coverage detected