Simply put, this is what you can do:
var memoria = "";
window.onkeyup = function(e) {
letra = String.fromCharCode(e.keyCode); // Capture a letra digitada
memoria += letra; // Adicione no final da memória
memoria = memoria.substr(-5); // Mantenha apenas as 5 ultimas letras
if (memoria == "STACK") {
alert("Parabéns!")
}
}
With each key you type, get the corresponding letter and store it in a string. When the end of this string is the same as the password, do something.
Just take care of cleaning up this memory so that it does not grow absurdly. In this example, a maximum of 5 characters is always kept, as this is the length of the password.