HighDots Forums  

Keypressing Not Working

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Keypressing Not Working in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dave (DreamIsle)
 
Posts: n/a

Default Keypressing Not Working - 08-07-2006 , 10:11 PM






I can't figure out why my keypress script is not working. I used the
following code:

document.onkeypress = KeyCheck;

function KeyCheck(e) {
var KeyID = (window.event) ? event.keyCode : e.keyCode;
//alert(KeyID);
switch(KeyID) {
case 13: title(); break;
case 37: move(-1); break;
case 38: toggle(1); break;
case 39: move(1); break;
case 40: toggle(1); break;
}
}

Here's my results:
-----------------------------------------------------------------------
Firefox: | Works fine.
IE: | Enter key works but arrow keys don't trigger the function.
Opera: | No keypresses work.

When I experienced problems, I tested the keypressing with the alert
you see in the comments of the code, but aside from working in FireFox
and the initial enter keypress in IE, nothing happened.

The whole page can be seen at http://thegriddle.net/rcr/ if you need to
see any of the other functions or the HTML or CSS. Any ideas or
suggestions would be great


Reply With Quote
  #2  
Old   
Wayne Dobson
 
Posts: n/a

Default Re: Keypressing Not Working - 08-08-2006 , 07:10 AM






"Dave (DreamIsle)" <davmillar (AT) gmail (DOT) com> wrote

Quote:
I can't figure out why my keypress script is not working. I used the
following code:

document.onkeypress = KeyCheck;

function KeyCheck(e) {
var KeyID = (window.event) ? event.keyCode : e.keyCode;
//alert(KeyID);
switch(KeyID) {
case 13: title(); break;
case 37: move(-1); break;
case 38: toggle(1); break;
case 39: move(1); break;
case 40: toggle(1); break;
}
}
"onkeypress" doesn't fire in IE, for the arrow keys. It works in IE, with
"onkeydown."

--
Wayne
AKA "Dobbie the House Elf"




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.