﻿if (document.captureEvents && Event.KEYUP) {
    //remove this part if you do not need Netscape 4 to work
    document.captureEvents(Event.KEYUP);
}

document.onkeyup = alertkey; //KeyCheck;
var aantal = 0;
function KeyCheck() {

    var KeyID = event.keyCode;

    if (KeyID == 27 | KeyID == 76) {
        aantal = aantal + 1
        if (aantal == 3) {

            window.location = "/account/logon";
            //$find('ctl00$Login$Login1$UserName').focus();
            aantal = 0;
        }
    }
    else {
        aantal = 0
    }
}


function alertkey(e) {
    if (!e) {
        //if the browser did not pass the event information to the
        //function, we will have to obtain it from the event register
        if (window.event) {
            //Internet Explorer
            e = window.event;
        } else {
            //total failure, we have no way of referencing the event
            return;
        }
    }
    if (e.keyCode == 27) {
        //DOM
        aantal = aantal + 1
        if (aantal == 3) {

            window.location = "/account/logon";
            //$find('ctl00$Login$Login1$UserName').focus();
            aantal = 0;
        }
    } else if (e.which == 27) {
        //NS 4 compatible
        aantal = aantal + 1
        if (aantal == 3) {

            window.location = "/account/logon";
            //$find('ctl00$Login$Login1$UserName').focus();
            aantal = 0;
        }
    } else if (e.charCode == 27) {
        //also NS 6+, Mozilla 0.9+
        aantal = aantal + 1
        if (aantal == 3) {

            window.location = "/account/logon";
            //$find('ctl00$Login$Login1$UserName').focus();
            aantal = 0;
        }
    } else {
        //total failure, we have no way of obtaining the key code
        return;
    }

}
