Results 1 to 2 of 2

Thread: Keypress Question

  1. #1

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496

    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>

  2. #2
    Lively Member Base's Avatar
    Join Date
    Aug 2001
    Location
    The Netherlands
    Posts
    65
    It should be something like: It return the key code value

    Code:
    window.alert(window.event.keyCode);
    Ok

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width