Click to See Complete Forum and Search --> : Key Launcher, Simple prob.


GavinPearce
05-11-2003, 07:23 AM
Edit:- Not sure if this link might come in useful. .http://www.webreference.com/js/tips/991024.html

Can some modify this script for me?

You press a key and it sends you to that page. Can you modify it so that you have to press Ctrl & Alt and the key to navigate to the page.



<!-- TWO STEPS TO INSTALL KEY LAUNCHER:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var key = new Array(); // Define key launcher pages here
key['h'] = "http://javascript.internet.com/index.html";
key['f'] = "http://javascript.internet.com/feedback.html";
key['n'] = "http://javascript.internet.com/new.html";
key['s'] = "http://javascript.internet.com/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>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
<table border=0><tr><td>
<pre>
This site equipped with Key Launcher!

The following launcher keys are available:

Press the letter 'h' for: Home Page
Press the letter 'f' for: Feedback Page
Press the letter 'n' for: What's New Page
Press the letter 's' for: Site Contents
</pre>
</td></tr></table>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.52 KB -->


Cheers.
Gav.:p

gil davis
05-11-2003, 07:44 AM
You can find out about Netscape's ALT and CTRL detection at http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/event.html#1196474 , and IE's detection at http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_event.asp (look at AltKey, AltLeft, CtrlKey and CtrlLeft).

You should be able to figure something out.

GavinPearce
05-11-2003, 07:46 AM
ok cheers. If anyone can do i for me, I'll still be glad because I have nearly no skills in javascript so i'll prob end up getting confused :p :confused:

GavinPearce
05-11-2003, 07:49 AM
like i thought lol i know what they are talking about but I have no idea how to get it into the script.

GavinPearce
05-11-2003, 12:26 PM
Anyone at all? :(

CrzySLAM
09-05-2005, 06:13 PM
I have a compatibility problem with this same JavaScript with FireFox and even NetScape. The problem lies in this line

eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;

I don't know enough about JavaScript, but I would really like to get this script to work for FireFox. If anyone can help, I would really appreciate it.