-
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>
-
It should be something like: It return the key code value
Code:
window.alert(window.event.keyCode);