473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Getting keycode from keypress event

Hi

I have:
<div onkeypress="go(event)">...</div>
and:

function go(event) {
alert(event.keyCode);
}

but I always get 0 for the keycode.

I am using Mozilla.
Thank you for your help.

Jul 20 '05 #1
3 39668
Scripsit "yzzzzz":
Hi

I have:
<div onkeypress="go(event)">...</div>
and:

function go(event) {
alert(event.keyCode);
}

but I always get 0 for the keycode.

I am using Mozilla.
Thank you for your help.

By the way, it works in IE. Is the property different in Mozilla/Netscape?

Jul 20 '05 #2
Scripsit "yzzzzz":
Scripsit "yzzzzz":
Hi

I have:
<div onkeypress="go(event)">...</div>
and:

function go(event) {
alert(event.keyCode);
}

but I always get 0 for the keycode.

I am using Mozilla.
Thank you for your help.

By the way, it works in IE. Is the property different in Mozilla/Netscape?


Ok

It's not *keyCode* it's *charCode*.
Now *that's* incompatibility.

Jul 20 '05 #3
yzzzzz wrote:
Scripsit "yzzzzz":
Scripsit "yzzzzz":
Hi

I have:
<div onkeypress="go(event)">...</div>
and:

function go(event) {
alert(event.keyCode);
}

but I always get 0 for the keycode.

I am using Mozilla.
Thank you for your help.

By the way, it works in IE. Is the property different in Mozilla/Netscape?


Ok

It's not *keyCode* it's *charCode*.
Now *that's* incompatibility.


The way events are handled and the properties they have are different between IE
and Mozilla.

IE has a global Event object attached to the default window object
(window.event). In Mozilla, the event is passed as the first parameter to the
event handler.

A list of event object properties in IE is available at: <url:
http://msdn.microsoft.com/workshop/a.../obj_event.asp
/>

A list of event object properties in Mozilla is available at:
<url: http://www.mozilla.org/docs/dom/domr...ef.html#999092 />

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #4

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

Similar topics

6
by: datactrl | last post by:
Hi, all Is that possible to fire a "tab" key press event with javascript? jack
2
by: znndrp | last post by:
Hi all, I've got a function that captures a keypress event. This is working fine, but in some cases I want to fire the same even again but with different parameters. Example; ...
4
by: phil_gg04 | last post by:
Dear Javascript Experts, I'm currently implementing Anyterm, a terminal emulator on a web page. It consists of an Apache module, some XmlHTTP and a bit of Javascript. The idea is to give you...
3
by: Darryn Ross | last post by:
Hi, I am trying to catch the KeyPress event on my datagrid but it isn't working... i have also tried registering the handler with the event like this... dgGLBatch.KeyPress += new...
3
by: Raul M. Colon | last post by:
Is possible to assign a click event to a button control in a Web form just pressing the return key? Something like windows forms where you can assign this action to a default control. For example,...
4
by: Tom | last post by:
I have a VB.NET user control that I wrote - this control has three or four other controls on it (textbox, combobox, datetime picker, etc). Now, whenever the control is on a form and the user enters...
4
by: Nathan Sokalski | last post by:
I am writing a piece of code for an ASP.NET function that generates an onKeyPress JavaScript eventhandler that uses the event.keyCode / event.which properties. I have two situations that I would...
1
by: centur | last post by:
Hello. I created simple asp.net application to search message history over Office Live Communicator conversations. I complete quite all job but stick with one thing - I have autosuggest box...
4
by: Claudia Fong | last post by:
I use keypress event to detect the characters users input, but it doesn't work with Alt tab.. I need to detect the combination Alt-A or Alt-F1.. how should I do? The code is below: private...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.