473,550 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keypressing Not Working

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

document.onkeyp ress = 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 :)

Aug 8 '06 #1
4 3752

Dave (DreamIsle) wrote:
I can't figure out why my keypress script is not working. I used the
following code:

document.onkeyp ress = KeyCheck;
Try:

document.onkeyu p
Tested in IE and Firefox - sorry, no Opera here:

<div id="xx"></div>
<script type="text/javascript">

document.onkeyu p = keyCheck;

function keyCheck(e) {
var e = e || window.event;
document.getEle mentById('xx'). innerHTML = e.keyCode;
}
</script>
--
Rob

Aug 8 '06 #2
Sorry Rob, but that isn't working for me either. Even the enter key
won't work with that.

Aug 8 '06 #3

Dave (DreamIsle) wrote:
Sorry Rob, but that isn't working for me either. Even the enter key
won't work with that.
Please quote what you are replying to. The code I posted 'works' in IE
and Firefox, do you mean it doesn't work in Opera?

Maybe you have other stuff that is stopping the event from bubbling,
have you tried onkeydown?
--
Rob

Aug 8 '06 #4
The code that you posted did not work in Internet Explorer. I have
changed the code to onkeydown and the up and down arrow keys work in IE
now, but the left and right keys do not work.

------------------------------------

document.onkeyd own = KeyCheck;

function KeyCheck(e) {
var e = e || window.event;
var KeyID = 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;
}
}

Aug 8 '06 #5

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

Similar topics

2
6245
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the reason..? Situation: I have a menu in my form, which is given a short key "Ctrl+P", now when the
6
3052
by: Mullin Yu | last post by:
hi, i have a web service that has file operations on Windows OS, and there may be a file concurrency issue if only one working directory e.g. c:\working therefore, i want to have a unique sub directory for each request so as to get rid of any file concurrency issue, e.g c:\working\unique-identifier1 for Request #1...
3
3097
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my working week definition. Lets say I have a working week definition of Monday through Friday, 9 am to 5 pm. Date1 = January 1st, 2005 at 8 am
8
1822
by: Hardy Wang | last post by:
Hi: Is it possible for me to create/open web application from remote machine other than port 80? And create application directly under virtual web site instead of creating a virtual directory? Because there is a developing server in our company running IIS with multiple web sites, each one has its own port number. In real scenario, no...
5
2797
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We have been looking our asses off but can not find a working solution. the code we came up with is ...
5
3046
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find out why it quit working. I found that if I didn't have a linkbutton, it quit working????????? If I changed the linkbutton to a regular button,...
8
2503
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs file (present under the Properties folder of the project) 3. Now I created a file called test.js on the root folder of the project,
2
14813
by: Don | last post by:
I'm having problems with intellisense, autocomplete, etc. suddenly not working in certain classes of a project I'm working on. All the options are set, and it all works fine for most classes, but for some it just suddenly stopped working. After a build it'll work maybe once or twice, then stop. I've tried repairing my installation of Visual...
9
3194
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. What it does is to call a webservice with two parameters, one being a integer, the other one being a "String" which contains XML (not the best...
0
7561
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...
0
7488
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...
0
7761
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. ...
0
7999
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...
0
6101
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...
0
5129
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...
1
1978
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
1
1094
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
801
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...

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.