Click to See Complete Forum and Search --> : CTRL + ALT + Go here


GavinPearce
05-12-2003, 01:55 PM
Rite I really have got stuck doing this script someone plase help, it's got my mind boggoling. I'm quite good at js for a 14 yr old but this has really got me confused, i have read and read and read about and but still can not figure it out. This three links have been given to me, perhaps you'll find them useful.

http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/event.html#1196474

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_event.asp

http://www.webreference.com/js/tips/991024.html


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var key = new Array(); // Define key launcher pages here
key['h'] = "index.html";
key['f'] = "feedback.html";
key['n'] = "new.html";
key['s'] = "toc.html";

function getKey(keyStroke) {
isNetscape=(document.layers);
// Cross-browser key capture routine couresty
// of Randy Bennett (rbennett@thezone.net)
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key) if (which == i) window.location = key[i];
}
document.onkeypress = getKey;
// End -->
</script>

Jona
05-12-2003, 02:18 PM
Originally posted by gavinnet
I'm quite good at js for a 14 yr old..

You're 14? Me too! LOL :p Anyways, I don't quite understand what your question is. Do you just need documentation on the script to learn from it?

GavinPearce
05-12-2003, 02:43 PM
Kool didn't no. U got messenger.

Nah i cant figure it out at all.

Can you perhaps do it for me. I need it so instead of just pressing the letter say H for home you press Ctrl + Alt + H

I need it so u press Ctrl + Alt as wel.

Jona
05-12-2003, 02:46 PM
OK, I can help you with that... You'll have to hang on for a few minutes, though.. Kinda busy. :p

Look at my profile for my IMs

GavinPearce
05-12-2003, 02:48 PM
k cheers loads.

Jona
05-12-2003, 03:06 PM
This works in IE.

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var key = new Array();
key['h'] = "index.html";
key['f'] = "feedback.html";
key['n'] = "new.html";
key['s'] = "toc.html";

function getKey(keyStroke) {
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key)
if(event.altKey==true && event.ctrlKey==true && which == i) window.location = key[i];
}
document.onkeydown = getKey;
// End -->
</script>

GavinPearce
05-12-2003, 03:09 PM
k cheers. can ya hav a go at netscape if possible it'll be great but if not no worries.

BTW i cant get hold of u wen i send u an IM on messenger.

Jona
05-12-2003, 03:11 PM
This should work in Netscape, although I haven't tested it because I don't have Netscape:

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var key = new Array();
key['h'] = "index.html";
key['f'] = "feedback.html";
key['n'] = "new.html";
key['s'] = "toc.html";

function getKey(keyStroke) {
if(window.Event){
alt = (keyStroke.modifiers & Event.ALT_MASK)? true: false;
ctrl = (keyStroke.modifiers & Event.CONTROL_MASK)? true: false;
} else {
alt = event.altKey;
ctrl = event.ctrlKey;}
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key)
if(alt==true && ctrl==true && which == i) window.location = key[i];
}
document.onkeydown = getKey;
// End -->
</script>

GavinPearce
05-12-2003, 03:14 PM
can u get the two put together so it works in both?

Lol im askin loads i no but im really tryin to get dis online 2nite and its 10pm nearly lol.