Results 1 to 6 of 6

Thread: advanced keypressing in Internet Explorer

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    advanced keypressing in Internet Explorer

    I've noticed some strange stuff when experimenting with keypressing in IE.
    I retrieve ASCICODE using window.event.keyCode (within document.onkeypress(). I can find out if ctrl was pressed using: window.event.ctrlKey.

    However when i press a character and the ctrl-key I get a different window.event.keyCode then I would without pressing the ctrl-key.

    example: pressing v gives me: 118, pressing v with ctrl gives me: 22 (with window.event.ctrlKey being true).

    How can I ever find out which character was pressed ?

    Also is it possible to catch alt+character I have not been able to de that, same goes for function keys (F.I. F1), i can't seem to catch them either...

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    For the ALT key it's:

    event.altKey
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Try this:
    Code:
    <script LANGUAGE = "JavaScript">
    function showKey(){
    alert(String.fromCharCode(event.keyCode));
    }
    
    document.onkeypress = showKey;
    
    </script>
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309
    So how do I detect if the f.i. "F2" key has been pressed ?

  5. #5
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    try this for the fx keys...
    Code:
    <script LANGUAGE = "JavaScript">
    function showKey(){
    event.returnValue = false;
    alert(event.keyCode + ' / ' + String.fromCharCode(event.keyCode));
    }
    
    document.onkeydown = showKey;
    
    </script>
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  6. #6
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    I don't think there's an onkeypress for the function keys...
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

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