Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Question key stroke capture NS7

    Any ideea why this script does not work in NS7... Looks OK to me...

    PHP Code:
    <html>
    <
    head>
    <
    script>
    function 
    NNKeyCap(thisOne) {
          if (
    thisOne.which == 13
           {
    alert('That\'s the ENTER key')};
    }

    function 
    IEKeyCap() 
    {
        if (
    window.event.keyCode == 13
           {
    alert('That\'s the ENTER key')};
    }

    if (
    navigator.appName == 'Netscape')
    {
    window.captureEvents(Event.KEYPRESS);window.onKeyPress NNKeyCap;}
    else{
    window.onKeyPress IEKeyCap;}
    //-->
    </script>
    </head>
    <body>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    this forum ignore my back slash. ok, look at:

    Any ideea why this script does not work in NS7... Looks OK to me...

    PHP Code:
    <html>
    <
    head>
    <
    script>
    function 
    NNKeyCap(thisOne) {
          if (
    thisOne.which == 13
           {
    alert('That is the ENTER key')};
    }

    function 
    IEKeyCap() 
    {
        if (
    window.event.keyCode == 13
           {
    alert('That is the ENTER key')};
    }

    if (
    navigator.appName == 'Netscape')
    {
    window.captureEvents(Event.KEYPRESS);window.onKeyPress NNKeyCap;}
    else{
    window.onKeyPress IEKeyCap;}
    //-->
    </script>
    </head>
    <body>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    event handlers should be lowercase.
    But I think the captureEvents technique is for NS4 only.
    You can now directly assign the window event handlers in NS6+ just like in IE

    window.onkeypress = function(e){
    var k = (e) ? e.which:event.keyCode;
    if (k==13) alert("That is ENTER key.")
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Thanks, this works for NS7, but not for IE6...

    I suppose IE6 don't support window.onkeyup as an event handler
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Try this:

    document.onkeyup = function(e){
    var k = (e) ? e.which:event.keyCode;
    alert(k);
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    yea, that should work, thanks!
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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