te******@gmail.com wrote:
is there ANYWAY to have a variable monitor keystrokes on an active page
with javascript and if x keys are pressed, show an alert? in other
words If I'm on the site and I type in "login", it alerts me saying
"You just typed login" with a kind of if (var == 'login') {
alert('alert') } etc, thanks guys.
Yeah I think the start of what you need is something like
typed = "";
document.onkeypress=monitorFunc;
function monitorFunc(e) {
keyCode = (e)? e.keyCode : window.event.keyCode;
char = String.fromCharCode(keyCode).toLowerCase();
typed += char;
}
You should implement backspace and clear the typed variable when enter
is pressed, keyCode for backspace is 8, return is 13.