M
mflll
I am having trouble responding writing a Javascript Program respond
to keypresses on top of a paragraph. Here is the code I tried:
<HTML>
<SCRIPT Language="JavaScript">
document.write("TEeve");
function QQ(event){
alert("Key Pressed " + event.charCode());
}
</SCRIPT>
<P onkeypress="QQ(event)">Testing</P>
The alert is not displayed when I click on the paragraph and press
ordinary
keys.
By the way the following related Javascript to respond to mouse events
on a
paragraph does work.
<HTML>
<SCRIPT Language="JavaScript">
document.write("Tex");
function QQ(event){
alert("Displaying Mouse Coordiantes "+event.clientX
+","+event.clientY);
}
</SCRIPT>
<body>
<P onmousedown="QQ(event)">Testing</P>
</body>
</html>
Thus, what don't I understand about the keypressed event?
I am running Mozilla 5.0 (rv:1.7.10 Geck/200507
I also tried someother options suggested by the W3C Level Tw Events
Specification.
But section 1.6.3 said that "the DOM Level 2 Event specification does
not provid
a key event module."
Dr. Leff, Western Illinois University FAX 309 298 2302 Pager 309 367
0787
Associate Professor of Computer Science, One University Circle, Macomb
IL 61455
to keypresses on top of a paragraph. Here is the code I tried:
<HTML>
<SCRIPT Language="JavaScript">
document.write("TEeve");
function QQ(event){
alert("Key Pressed " + event.charCode());
}
</SCRIPT>
<P onkeypress="QQ(event)">Testing</P>
The alert is not displayed when I click on the paragraph and press
ordinary
keys.
By the way the following related Javascript to respond to mouse events
on a
paragraph does work.
<HTML>
<SCRIPT Language="JavaScript">
document.write("Tex");
function QQ(event){
alert("Displaying Mouse Coordiantes "+event.clientX
+","+event.clientY);
}
</SCRIPT>
<body>
<P onmousedown="QQ(event)">Testing</P>
</body>
</html>
Thus, what don't I understand about the keypressed event?
I am running Mozilla 5.0 (rv:1.7.10 Geck/200507
I also tried someother options suggested by the W3C Level Tw Events
Specification.
But section 1.6.3 said that "the DOM Level 2 Event specification does
not provid
a key event module."
Dr. Leff, Western Illinois University FAX 309 298 2302 Pager 309 367
0787
Associate Professor of Computer Science, One University Circle, Macomb
IL 61455