473,320 Members | 1,856 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,320 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 39661
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.