﻿var allowShortcuts = true;

function EditKeyCommand(evt) {
    var key = (evt.which || evt.charCode || evt.keyCode);
    var stringKey = String.fromCharCode(key).toLowerCase();
    var cmd = '';
    if (!evt || !evt.ctrlKey) {
        return true;
    }
    switch (stringKey) {
        case 's':
            {
                if (evt.preventDefault) {
                    evt.preventDefault();
                    evt.stopPropagation();
                }
                else {
                    evt.returnValue = false;
                    evt.cancelBubble = true;
                }
                if (!window.disableShortcuts) {
                    if (window.SaveDocument) {
                        SaveDocument();
                    }
                    else if ((window.parent != null) && window.parent.SaveDocument) {
                        window.parent.SaveDocument();
                    }
                }
                return false;
            }
    };
    return true;
}

if (document.addEventListener) {
    document.addEventListener("keypress", EditKeyCommand, true);
}
else if (document.attachEvent) {
    document.attachEvent("onkeydown", function(evt) { EditKeyCommand(evt) });
}