0

<html>

<head>
<title>New Page 11</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<script language="JavaScript1.2">
if (document.layers)
document.captureEvents(Event.KEYPRESS)
function backhome(e){
var targeturl="index.htm"
if (document.layers){
if (e.which==104||e.which==72)
window.location=targeturl
}
else if (document.all){
if (event.keyCode==104||event.keyCode==72)
window.location=targeturl
}
}
document.onkeypress=backhome
</script>
</head>

<body>

<p align="center">Hit The(H) key on your keyboard to send you to a home page that you
configure!!</p>
</body>
</html>

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by hielo
0

You can handle the keys pressed on the keyboard:

document.onkeypress = function(e) {
 return HandleKey(e);
}

function HandleKey(event2) {

     var key;  
     
     /* Retrieving the pressed key: */
	 
     if (window.event) {
          key = window.event.keyCode; //IE
     } else {
          key = event2.which; //firefox    
     }
	 
     /* Switching the pressed key: */
	 
     if (key == 97) {
	 
	alert("You pressed the left arrow!");
	return false;
		
     } 
	 
}

You only need to find the keycode of the "H" key.

~G

Edited by Graphix: n/a

0

You only need to find the keycode of the "H" key.

His code already has that.
72 == H
104 == h

Edited by hielo: n/a

0

Good job you figured that out

You are obviously missing the point

murtazamzk, try:

<script>
function backhome(e){
	var targeturl="index.htm"
	if (document.all)
	{
		if (event.keyCode==104||event.keyCode==72)
			window.location=targeturl
	}
	else
	{
		if (e.which==104||e.which==72)
			window.location=targeturl
	}
}
document.onkeypress=backhome
</script>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.