473,667 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching cursorkeys in IE

Hi,

The following snip works totally ok in a Gecko browser, for the 'normal keys as well as the cursorkeys.

<p>Key in the searchable 'thing':<br />
<input type="text" value="" id="txt1" onkeypress="var e= event; alert(e.keyCode );" />
</p>

In IE 5+ however the cursokeys do NOT register at all.
Insofar as I have been able to gather the keyCode property should be supported by IE (which is probably a
misundestanding from my side).
What *would* be the correct way to catch the cursorkeys?

TIA
Fermin DCG
Jul 20 '05 #1
6 1473


F. Da Costa wrote:
The following snip works totally ok in a Gecko browser, for the 'normal
keys as well as the cursorkeys.

<p>Key in the searchable 'thing':<br />
<input type="text" value="" id="txt1" onkeypress="var e= event;
alert(e.keyCode );" />
</p>

In IE 5+ however the cursokeys do NOT register at all.
Insofar as I have been able to gather the keyCode property should be
supported by IE (which is probably a misundestanding from my side).
What *would* be the correct way to catch the cursorkeys?


I think IE fires only keydown and keyup events for cursor keys.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
F. Da Costa wrote:
Hi,

The following snip works totally ok in a Gecko browser, for the 'normal
keys as well as the cursorkeys.

<p>Key in the searchable 'thing':<br />
<input type="text" value="" id="txt1" onkeypress="var e= event;
alert(e.keyCode );" />
</p>
MS does not like onKeyPress! Using onKeyDown seems to work ok (don't ask why).
In IE 5+ however the cursokeys do NOT register at all.
Insofar as I have been able to gather the keyCode property should be
supported by IE (which is probably a misundestanding from my side).
What *would* be the correct way to catch the cursorkeys?

TIA
Fermin DCG

Jul 20 '05 #3
F. Da Costa wrote:
The following snip works totally ok in a Gecko browser, for the 'normal keys as well as the cursorkeys.
RFC 2822, section 2.1.1, calls for a reasonable maximum of 78 characters
per line. Please set your automagic linebreak then to recommended 72 to
76 characters per line in order not to exceed that maximum when quoting
others or being quoted. I guess the preference can be set with Edit,
Preferences, Composition, Composing Messages, Wrap plain text messages
at [__] characters in Mozilla Thunderbird as it can in Mozilla MailNews.
For I know that Thunderbird is a comparably young project, if there is
no preference (RTFM!) you should consider to update your Thunderbird.
<p>Key in the searchable 'thing':<br />
<input type="text" value="" id="txt1" onkeypress="var e= event; alert(e.keyCode );" />
</p>


In addition to what Martin wrote:

Do not declare a global variable in an event handler.
For general keyboard event handling, you would use

function handlerFunction (e)
{
var keyCode =
(e.which
? e.which
: (e.keyCode
? e.keyCode
: 0));

if (keyCode ...)
{
...
}
}

<... onwhatever="han dlerFunction(ev ent);" ...>
HTH

PointedEars
Jul 20 '05 #4
Thomas 'PointedEars' Lahn <Po*********@we b.de> writes:
function handlerFunction (e)
{
var keyCode =
(e.which
? e.which
: (e.keyCode
? e.keyCode
: 0));


FWIW, (foo ? foo : bar) can be written shorter as (foo || bar).
That means that your code above can be written as
var keyCode = e.which || e.keyCode || 0;

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5
JRS: In article <3F************ **@PointedEars. de>, seen in
news:comp.lang. javascript, Thomas 'PointedEars' Lahn
<Po*********@we b.de> posted at Mon, 15 Dec 2003 00:21:46 :-
F. Da Costa wrote:
The following snip works totally ok in a Gecko browser, for the 'normal keys

as well as the cursorkeys.

RFC 2822, section 2.1.1, calls for a reasonable maximum of 78 characters
per line. Please set your automagic linebreak then to recommended 72 to
76 characters per line in order not to exceed that maximum when quoting
others or being quoted.
...

That should not be done, except in a truly intelligent editor, if you
are likely to want to post long lines of HTML or of script (which you
did).

It is of *primary* importance that script, at least, should not be
artificially broken.

The need, therefore, with most systems, is to post with margins at least
as wide as the included code. Obviously, it is then a good thing to
write your HTML, and your script, within a reasonable margin of about 72
characters; and, if you cannot do so, you need to control the length of
lines in plain text by other means, such as by inserting breaks
manually.

TL is a Mussolini wannabe, but does not really understand the proper use
of News.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 20 '05 #6
Lasse Reichstein Nielsen wrote:
FWIW, (foo ? foo : bar) can be written shorter as (foo || bar).
That means that your code above can be written as
var keyCode = e.which || e.keyCode || 0;


n1, thx :)
\V/ PointedEars
Jul 20 '05 #7

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

Similar topics

8
1732
by: Adam H. Peterson | last post by:
Hello, I sometimes find myself writing code something like this: try { Derived &d=dynamic_cast<Derived&>(b); d.do_something_complicated(); // etc.... } catch (std::bad_cast) { throw Base_error("An object of incorrect type was given....");
1
7830
by: Chris LaJoie | last post by:
Hi, I have a question regarding the catching of popups in a separate window. I just can't get it to work. My browser is extremely simple and is designed for a single purpose: to open a 'netlet' to a particular VPN on the United Airlines network. The trouble is, I can't get my app to catch the popup (which is the netlet). The netlet opens outside in a separate IE window instead. I have a VB6 app that does what I want perfectly fine...
7
2332
by: cmay | last post by:
FxCop complains every time I catch System.Exception. I don't see the value in trying to catch every possible exception type (or even figuring out what exceptions can be caught) by a given block of code, when System.Exception seems to get the job done for me. My application is an ASP.Net intranet site. When I catch an exception, I log the stack trace and deal with it, normally by displaying an error
12
6103
by: Vasco Lohrenscheit | last post by:
Hi, I have a Problem with unmanaged exception. In the debug build it works fine to catch unmanaged c++ exceptions from other dlls with //managed code: try { //the form loads unmanaged dlls out of which unmanaged exception //get thrown
7
6384
by: Derek Schuff | last post by:
I'm sorry if this is a FAQ or on an easily-accesible "RTFM" style page, but i couldnt find it. I have some code like this: for line in f: toks = line.split() try: if int(toks,16) == qaddrs+0x1000 and toks == "200": #producer write prod = int(toks, 16)
2
2352
by: Eric Lilja | last post by:
Hello, consider this complete program: #include <iostream> #include <string> using std::cout; using std::endl; using std::string; class Hanna {
5
2602
by: lord.zoltar | last post by:
How can I prevent the big close button in the top of the window from closing the window? I want to have and "are you sure?" confirmation so the user must press "Yes" before the program ends. Right now, I've tried catching the FormClosing and FormClosed events. The message box appears at the right time, but since the form is already closing, it doesn't matter if the user presses "Yes" or "No". how do I cancel the FormClosing?
2
3468
by: fischermx | last post by:
Exception Catching difference between VC++ and C# In C# I have this: try { int x, y, z; x = 20; y = 0;
3
3280
by: john | last post by:
I wrapped some fortran code using F2PY and need to be able to catch fortran runtime errors to run the following: # "grid" is a wrapped fortran module # no runtime errors incurred when run with the correct inputs for filetype #------------------------------- def readGrid( self, coord='xyz' ): mg = ( '.FALSE.', '.TRUE.' ) form = ( 'FORMATTED', 'UNFORMATTED' )
0
8458
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8366
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
8888
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
8790
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
8565
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
5677
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();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
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.