473,775 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cross browser key handler?

Hi has anyone got a function that can detect a user pressing a key
that works cross browser?
I just want to redirect my visitor if they hit escape ... you'd think
it would be easy!
Thanks,
Ciarán

May 21 '07 #1
8 5535
Ciaran said the following on 5/21/2007 12:43 PM:
Hi has anyone got a function that can detect a user pressing a key
that works cross browser?
I just want to redirect my visitor if they hit escape ... you'd think
it would be easy!
As easy as posting the same question 6 times?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 21 '07 #2
On May 21, 6:11 pm, Randy Webb <HikksNotAtH... @aol.comwrote:
Ciaran said the following on 5/21/2007 12:43 PM:
Hi has anyone got a function that can detect a user pressing a key
that works cross browser?
I just want to redirect my visitor if they hit escape ... you'd think
it would be easy!

As easy as posting the same question 6 times?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptT oolbox.com/bestpractices/

Very funny. That was a server error.

May 21 '07 #3
Ciaran said the following on 5/21/2007 3:18 PM:
On May 21, 6:11 pm, Randy Webb <HikksNotAtH... @aol.comwrote:
>Ciaran said the following on 5/21/2007 12:43 PM:
>>Hi has anyone got a function that can detect a user pressing a key
that works cross browser?
I just want to redirect my visitor if they hit escape ... you'd think
it would be easy!
As easy as posting the same question 6 times?
Very funny. That was a server error.
The server caused you to click the Post button 6 times? That is one
powerful server you have there.

On further inspection, you are posting using Google Groups and I doubt -
very seriously - that the GG server has the ability to cause you to
click a button 6 times. But, nice try.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 21 '07 #4
On May 21, 5:43 pm, Ciaran <cronok...@hotm ail.comwrote:
Hi has anyone got a function that can detect a user pressing a key
that works cross browser?
I just want to redirect my visitor if they hit escape ... you'd think
it would be easy!
Thanks,
Ciarán
Anyone?

May 23 '07 #5
On May 21, 10:43 am, Ciaran <cronok...@hotm ail.comwrote:
Hi has anyone got a function that can detect a user pressing a key
that works cross browser?
I just want to redirect my visitor if they hit escape
try:

document.body.o nkeypress=
function(e){
if((e||event).k eyCode==27)
location.href=" http://google.com";
}

untested

May 23 '07 #6
On May 23, 11:35 pm, "scripts.contac t" <scripts.cont.. .@gmail.com>
wrote:
On May 21, 10:43 am, Ciaran <cronok...@hotm ail.comwrote:
Hi has anyone got a function that can detect a user pressing a key
that works cross browser?
I just want to redirect my visitor if they hit escape

try:

document.body.o nkeypress=
function(e){
if((e||event).k eyCode==27)
location.href=" http://google.com";

}

untested

Thanks for the reply! .... but it doesnt seem to be working. I have
this function working in IE but FF is ignoring it ...

if (document.layer s) { document.captur eEvents(Event.K EYPRESS); }
document.onkeyp ress = getKey;
function getKey(keyStrok e) {
var keyCode = (document.layer s) ? keyStroke.which : event.keyCode;
if(keyCode==27) location.href=' quit.html';
}

May 23 '07 #7
On May 23, 5:33 pm, Ciaran <cronok...@hotm ail.comwrote:
document.body.o nkeypress=
function(e){
if((e||event).k eyCode==27)
location.href=" http://google.com";
}

Thanks for the reply! .... but it doesnt seem to be working. I have
this function working in IE but FF is ignoring it ...
Try this:

document.onkeyp ress=changeHREF
function changeHREF(ev){
ev=ev||event;
if(ev.keyCode== 27){
location.href=" http://google.com"
return false
}
}

works in o9,f2,i6

May 23 '07 #8
On May 24, 12:52 am, "scripts.contac t" <scripts.cont.. .@gmail.com>
wrote:
On May 23, 5:33 pm, Ciaran <cronok...@hotm ail.comwrote:
document.body.o nkeypress=
function(e){
if((e||event).k eyCode==27)
location.href=" http://google.com";
}
Thanks for the reply! .... but it doesnt seem to be working. I have
this function working in IE but FF is ignoring it ...

Try this:

document.onkeyp ress=changeHREF
function changeHREF(ev){
ev=ev||event;
if(ev.keyCode== 27){
location.href=" http://google.com"
return false
}
}

works in o9,f2,i6
Wow! perfect! and such an elegant solution! I searched the net for a
key handler like this and everything I found was either 2 pages long
or only worked in ie. Thanks a lot!
Ciarán

May 24 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8295
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two dropdown lists. If you change the selection of the left one (e.g. choose parentoption2), it should open up page2.htm in a popup window.
16
2874
by: Java script Dude | last post by:
To all Mozilla JS Guru's (IE dudes welcome), I have spent the last three years developing complex DHTML applications that must work in IE 5.5sp2+ but I use Mozilla 1.3+** to do all my development. I have build some cross browser debuggers so my users can send me verbose debug dumps. I have some success but have come to a roadblock with the basic underlying JavaScript models. The only way to get a complete stack in IE is to use the...
1
3696
by: cjl | last post by:
Hey all: I'm trying to write a cross-browser (IE and firefox) event handler for the mousewheel. Basically my web app is an image viewer, so if you scroll "down" with the wheel the next image should be displayed and if you scroll "up" the previous image should be displayed. So far I have: function handleMouseWheel(e)
17
1792
by: Mark Rae | last post by:
Hi, I'm interested in your opinion concerning how far you would consider it necessary to code for cross-browser compatibility these days, especially for public-facing Internet sites... According to a recent survey (http://www.weboptimiser.com/search_engine_marketing_news/3061148.html), Internet Explorer has just under 95% of the browser marketplace. Do you think it's worth the additional aggravation of making things work in
15
2330
by: CMM | last post by:
So I'm half way through overseeing a large project in ASP.NET 2.0. My superiors have decided that it would be nice if we ensured the site worked on all the major platforms (as they see it: IE, FireFox, and Safari). We've made heavy usage of the new MENU control and other intrinsic 2.0 controls.... nothing fancy! just using ASP.NET's built-in controls and very nice, pervasive, and clean usage of CSS. Now I find after more testing that the...
2
11771
by: mattgarvin | last post by:
Hello, I need a piece of javascript that will allow a form to be submitted when Enter is pressed for IE6 and 7, Firefox 2, and recent versions of Safari. It is for a login page that has two textboxes: a "Login" and a "Password". The "Login Button" is actually a standard image with an onClick event handler to submit the form, because we use a mouseover effect. (That is, it is not INPUT TYPE="IMAGE" but rather an IMAGE tag with...
1
1765
by: Ciaran | last post by:
Hi Does anyone have a simple function that captures a keystroke that works cross browser? I just want to redirect a page when a user hits esc... you'd think it would be easy! Cheers, Ciarán
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10107
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6718
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.