Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you open a window with muliple keypress?

Status
Not open for further replies.

tivaelydoc

Technical User
Jul 4, 2007
6
0
0
There is this script:


and instead of it opening on just one key, I want it to open on several keys (one after another, like A then D then F), but how do I?

I think this is the main part:

if (ns4)
document.captureEvents(Event.KEYPRESS)
function menuengine(e){
if (ns4||ns6){
if (e.which==120)
pull()
if (e.which==122)
draw()
}
else if (ie4){
if (event.keyCode==120)
pull()
if (event.keyCode==122)
draw()
}
}
document.onkeypress=menuengine
 
Store each matching keypress in a global variable... and only trigger the function when all keys have been pressed.

Show us the code you have been working on for this and we can help if you get stuck.

Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
var captcha = new Array();
var edits = new Array();

var cheatCode = '3838404037393739989713';
var cheat = '';
$j(document).keypress(function(key) {
if (cheat.length < cheatCode.length) {
var k = (key.keyCode == 0) ? key.charCode : key.keyCode;
cheat = cheat + String(k);
if (cheat == cheatCode) {
$j('#c-rply-to0').expandAll();
}
}
});

(source: )

See the 3838404037393739989713? That's up up down down etc...What I want to do is is set up a code like that on my page, using a simple :

<script language="JavaScript">
document.onkeydown = checkKeycode
function checkKeycode(e) {
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
if(keycode == 13){
alert("example");
}
}
</script>

code, but I don't know how.
 
Well I found/made a code that works.

<script language="JavaScript">
var cheatCode = "all your base are belong to us".toUpperCase();
var codeIndex = 0;

function executeCheat() {
alert("h4x3d!!!1!11");
}

function codeHandler(e) {
if(!e) e = window.event;
var k = e.keyCode? e.keyCode: e.which;
if(!(k==cheatCode.charCodeAt(codeIndex++))) {
codeIndex = 0;
return;
}
else if(codeIndex==cheatCode.length) executeCheat();
}

document.addEventListener? document.addEventListener("keydown",
codeHandler, false): document.attachEvent("onkeydown", codeHandler);
</script>

But instead of it opening the alert, I want it to open a iframe:

<a href="example.jpg" rel="lightbox[1337]" title="h4x3d!!!1!11">all
your base are belong to us</a>

But this is not a ordinary iframe. It doesn't have a separate url, so I
couldn't place a script code in the parent url:


So what do I do?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top