I'm having trouble using the chrome.commands.getAll API in creating a Chrome Extension. The main function returns before the closure is executed meaning the return value is wrong.
Is it possible to synchronise this without an external library?
var find = function()
{
    var shortcut = null;
    chrome.commands.getAll(function(commands){
        //Assigning the shortcut (more stuff happens in here in the actual code - I have shortened it for simplicity)
        shortcut = 'foo';
    });
    return shortcut;
};
