$(document).ready(function () {

//     $(document).keydown(function(event) {

//     if (!event.altKey) return;

//     switch (event.key.toLowerCase()) {
//         case 'h': $(".postamt").focus(); break;
//         case 's': $("#submit")[0]?.click(); break;
//         case 'a': $("#add")[0]?.click(); break;
//         case 'c': $("#cancel")[0]?.click(); break;
//         case 'd': $("#delete")[0]?.click(); break;
//         case 'q': $("#exit")[0]?.click(); break;
//         case 'b': $("#previous")[0]?.click(); break;
//         case 'n': $("#next")[0]?.click(); break;
//         case 'e': $("#edit")[0]?.click(); break;
//         case 'p': $("#print")[0]?.click(); break;
//         case 'f':
//             $(".bs-example-modal-lg").modal("show");
//             break;
//         default:
//             return;
//     }

//     event.preventDefault();
// });


    $(document).keydown(function (event) {
        //19 for Mac Command+S

        if (!(String.fromCharCode(event.which).toLowerCase() == 'h' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $(".postamt").focus();
        event.preventDefault();
        return false;

    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 's' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#submit").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'a' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#add").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'c' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#cancel").click();
        event.preventDefault();
        return false;
    });


    $(document).keydown(function(event) {
        if (event.altKey && event.key.toLowerCase() === 'd') {
            $('a[id="delete"]')[0].click();
            event.preventDefault();
            return false;
        }
    });

    // $(document).keydown(function (event) {
    //     //19 for Mac Command+S
    //     if (!(String.fromCharCode(event.which).toLowerCase() == 'd' && event.altKey) && !(event.which == 19))
    //         return true;
    //     //alert("Ctrl-s pressed");
    //     $("#delete").click();
    //     event.preventDefault();
    //     return false;
    // });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'q' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#exit").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'b' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#previous").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'n' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#next").click();
        event.preventDefault();
        return false;
    });

//    $(document).keydown(function (event) {
//        //19 for Mac Command+S
//        if (!(String.fromCharCode(event.which).toLowerCase() == 'f' && event.altKey) && !(event.which == 19))
//            return true;
//        //alert("Ctrl-s pressed");
//        $("#search").click();
//        event.preventDefault();
//        return false;
//    });

    $(document).keydown(function (event) {

        if (!(String.fromCharCode(event.which).toLowerCase() == 'f' && event.altKey))
            return true;

        $(".bs-example-modal-lg").modal("show");

        event.preventDefault();
        event.stopImmediatePropagation();

        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'e' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#edit").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'p' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#print").click();
        event.preventDefault();
        return false;
    });


});