src/command/KeyBindingManager.js
function addBinding(command, keyBindings, platform) {
        var commandID = "",
            results;

        if (!command) {
            console.error("addBinding(): missing required parameter: command");
            return;
        }

        if (!keyBindings) { return; }

        if (typeof (command) === "string") {
            commandID = command;
        } else {
            commandID = command.getID();
        }

        if (Array.isArray(keyBindings)) {
            var keyBinding;
            results = [];

            // process platform-specific bindings first
            keyBindings.sort(_sortByPlatform);

            keyBindings.forEach(function addSingleBinding(keyBindingRequest) {
                // attempt to add keybinding
                keyBinding = _addBinding(commandID, keyBindingRequest, keyBindingRequest.platform);

                if (keyBinding) {
                    results.push(keyBinding);
                }
            });
        } else {
            results = _addBinding(commandID, keyBindings, platform);
        }

        return results;
    }
function addBinding(command, keyBindings, platform) {
        var commandID = "",
            results;

        if (!command) {
            console.error("addBinding(): missing required parameter: command");
            return;
        }

        if (!keyBindings) { return; }

        if (typeof (command) === "string") {
            commandID = command;
        } else {
            commandID = command.getID();
        }

        if (Array.isArray(keyBindings)) {
            var keyBinding;
            results = [];

            // process platform-specific bindings first
            keyBindings.sort(_sortByPlatform);

            keyBindings.forEach(function addSingleBinding(keyBindingRequest) {
                // attempt to add keybinding
                keyBinding = _addBinding(commandID, keyBindingRequest, keyBindingRequest.platform);

                if (keyBinding) {
                    results.push(keyBinding);
                }
            });
        } else {
            results = _addBinding(commandID, keyBindings, platform);
        }

        return results;
    }
function addBinding ( command , keyBindings , platform ) { var commandID = "" , results ; if ( ! command ) { console . error ( "addBinding(): missing required parameter: command" ) ; return ; } if ( ! keyBindings ) { return ; } if ( typeof ( command ) === "string" ) { commandID = command ; } else { commandID = command . getID ( ) ; } if ( Array . isArray ( keyBindings ) ) { var keyBinding ; results = [ ] ; // process platform-specific bindings first keyBindings . sort ( _sortByPlatform ) ; keyBindings . forEach ( function addSingleBinding ( keyBindingRequest ) { // attempt to add keybinding keyBinding = _addBinding ( commandID , keyBindingRequest , keyBindingRequest . platform ) ; if ( keyBinding ) { results . push ( keyBinding ) ; } } ) ; } else { results = _addBinding ( commandID , keyBindings , platform ) ; } return results ; }
Add one or more key bindings to a particular Command.

@param {!string | Command} command - A command ID or command object
@param {?({key: string, displayKey: string}|Array.<{key: string, displayKey: string, platform: string}>)} keyBindings
A single key binding or an array of keybindings. Example:
"Shift-Cmd-F". Mac and Win key equivalents are automatically
mapped to each other. Use displayKey property to display a different
string (e.g. "CMD+" instead of "CMD=").
@param {?string} platform The target OS of the keyBindings either
"mac", "win" or "linux". If undefined, all platforms not explicitly
defined will use the key binding.
NOTE: If platform is not specified, Ctrl will be replaced by Cmd for "mac" platform
@return {{key: string, displayKey:String}|Array.<{key: string, displayKey:String}>}
Returns record(s) for valid key binding(s)
Add one or more key bindings to a particular Command .