|
-
Dec 8th, 2001, 03:48 PM
#1
Thread Starter
PowerPoster
Keypress Question
Sorry if this is an obvious question, but I am new to javascript. I'm simply trying to display a message that shows which key the user has pressed, however, this script will not work.
Code:
<HTML>
<HEAD>
<TITLE>Descriptive Links</TITLE>
<script Language="javascript">
function describe(text) {
window.status = text;
return true;
}
function clearstatus() {
window.status = "";
}
</script>
</HEAD>
<BODY onKeyPress = "window.alert('You pressed ' + String.fromCharCode(event.which));">
<H1>Descriptive Links</H1>
<P>Move the mouse pointer over one of these links to view a description</P>
<ul>
<li><a href="order.html" onMouseOver="return(describe('Order a product'));"
onMouseOut = "clearstatus();">Order Form</a>
</ul>
</body>
</html>
-
Dec 10th, 2001, 06:45 AM
#2
Lively Member
It should be something like: It return the key code value
Code:
window.alert(window.event.keyCode);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|