Opening window with multiple keypress?? Newbie

R

Robin Goodfellow

Hi,

I know that this is probably very basic but I am looking for a bit of help.
I have a website running at the moment but I want to have a log in screen
that is hidden, so I want to be able to capture a specific sequence of
kepress' or even multiple keys held down at the same time to open the login
screen.

I have been trying to read up on this but I am getting nowhere at all, could
anyone please help.

Thanks in advance
 
E

Evertjan.

Robin Goodfellow wrote on 30 jun 2003 in comp.lang.javascript:
Hi,

I know that this is probably very basic but I am looking for a bit of
help. I have a website running at the moment but I want to have a log
in screen that is hidden, so I want to be able to capture a specific
sequence of kepress' or even multiple keys held down at the same time
to open the login screen.

To get you started:

<script>
function fill(x){
if(x==27){empty();return}
if(x!=13)return // any other key will just append a char.
if(document.getElementById("in").value.toLowerCase()=="mypassword")
location.href="/loggedin.html"
// else:
empty()
}

function empty(){
document.getElementById("in").value=""
document.getElementById("in").focus()
}
</script>


<body
onload='empty()'
oncontextmenu="empty();return false">

<input id=in name=in value=""
style="visibility:hidden;"
onkeydown="fill(event.keyCode)">

Securitywise clientside passwords are nonsense, of course !!
 
L

Lasse Reichstein Nielsen

Robin Goodfellow said:
Hi,

I know that this is probably very basic but I am looking for a bit of help.
I have a website running at the moment but I want to have a log in screen
that is hidden, so I want to be able to capture a specific sequence of
kepress' or even multiple keys held down at the same time to open the login
screen.

Try something like this:
---
function doSomething() {alert("SUCCESS!");}

document.documentElement.onkeypress = function (event) {
event = event || window.event; // IE sucks
var key = event.which || event.keyCode; // IE uses .keyCode, Moz uses .which
if ((key == 76 || key == 12 || key == 108) && // "L" "^L" or "l"
event.shiftKey && event.ctrlKey) {
doSomething();
if (event.preventDefault) { event.preventDefault(); }
else {event.returnValue = false;} // IE sucks
}
}
---
This triggers the doSomething function when you press Shift+Ctrl+L,
and works in Mozilla, IE6 and Opera in standards mode.
(I'm not sure whether the key==108 is necessary, but I would keep it
to be sure).

/L
 
R

Robin Goodfellow

So would I put
<SCRIPT LANGUAGE="JavaScript1.2">
then your code
</SCRIPT>

do I need to put anything in the body, when I say begineer I mean I have
only been at this a couple of hours !!!

Thanks for replying
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top