$(document).ready(function() {
    $(document).keyup(function(event) {
        // prevent if in one of these form elements
        var sourceTag = $(event.target).get(0).tagName.toLowerCase();
        if (sourceTag == "input" || sourceTag == "select" || sourceTag == "textarea") return;

        switch (event.which) {
            case 65: // all
                $("input#showall").click();
                break;

            case 69: // enter
                $("textarea#msg").focus();
                if (typeof CKEDITOR === "undefined") return;
                CKEDITOR.instances.msg.focus();
                break;

            case 71: // goto
                $("input#goto").click();
                break;

            case 76: // logout
                $("input#logout").click();
                break;

            case 77: // moo
                $("input#moo").click();
                break;

            case 78: // new
                $("input#shownew").click();
                break;

            case 83: // skip
                $("input#skip").click();
                break;

            case 85: // ungoto
                $("input#ungoto").click();
                break;

            case 90: // z
                $("input#forget").click();
                break;

            //            default: 
            //                console.log(event.which); 
            //                break; 
        }
    });
});

