Mousetrap = (function (Mousetrap) {
    'use strict';
    var self = Mousetrap,
        _oldBind = self.bind,
        _oldUnbind = self.unbind,
        args;

    self.stopCallback = function (e, element) {

        // if the element has the class "mousetrap" then no need to stop
        if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
            return false;
        }

        // stop for input, select, and textarea
        return ['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON'].indexOf(element.tagName) > -1 || element.isContentEditable;
    };

    self.bind = function () {
        args = arguments;

        // normal call
        if (typeof args[0] === 'string' || args[0] instanceof Array) {
            return _oldBind.apply(this, args);
        }

        // object passed in
        for (var key in args[0]) {
            if (args[0].hasOwnProperty(key)) {
                _oldBind(key, args[0][key], args[1]);
            }
        }
    };
    self.unbind = function () {
        args = arguments;

        // normal call
        if (typeof args[0] === 'string' || args[0] instanceof Array) {
            return _oldUnbind.apply(this, args);
        }

        // object passed in
        for (var key in args[0]) {
            if (args[0].hasOwnProperty(key)) {
                _oldUnbind(key, args[1]);
            }
        }
    };
    return Mousetrap;
})(Mousetrap);