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

Function _pickBestAction

client/vendors/mousetrap.js:631–646  ·  view source on GitHub ↗

* picks the best action based on the key combination * * @param {string} key - character for key * @param {Array} modifiers * @param {string=} action passed in

(key, modifiers, action)

Source from the content-addressed store, hash-verified

629 * @param {string=} action passed in
630 */
631 function _pickBestAction(key, modifiers, action) {
632
633 // if no action was picked in we should try to pick the one
634 // that we think would work best for this key
635 if (!action) {
636 action = _getReverseMap()[key] ? 'keydown' : 'keypress';
637 }
638
639 // modifier keys don't work as expected with keypress,
640 // switch to keydown
641 if (action == 'keypress' && modifiers.length) {
642 action = 'keydown';
643 }
644
645 return action;
646 }
647
648 /**
649 * binds a key sequence to an event

Callers 1

_getKeyInfoFunction · 0.85

Calls 1

_getReverseMapFunction · 0.85

Tested by

no test coverage detected