Loading ...
Sorry, an error occurred while loading the content.

Re: [JavaScript] Re: Caps Lock

Expand Messages
  • AJ Batac
    Thanks. This function will be very useful for login. Hope there s other way to warn the user that the CAPS is on even before the login isn t it? Regards, AJ
    Message 1 of 8 , Aug 1, 2004
    • 0 Attachment
      Thanks. This function will be very useful for login. Hope there's
      other way to warn the user that the CAPS is on even before the login
      isn't it?

      Regards,
      AJ

      On Sun, 01 Aug 2004 09:50:03 +1000, Jon Stephens <jon@...> wrote:
      > Unfortunately, the answer to your question is No.
      >
      > Best you can do is to check the case of what's entered, and if you get a
      > number of caps in a row, warn the user.
      >
      > document.forms[0].myTextInput.onkeypress = checkCaps;
      >
      > function checkCaps()
      > {
      > var entered = document.forms[0].myTextInput.value;
      >
      > if(entered.length >= 10 && entered == entered.toUpperCase())
      > alert("Check your caps lock key, please.");
      > }
      >
    • Venkat V
      Hi, There is another method of capturing caps-lock (although not 100% foolproof)... Check it out... function checkCapsLock( e )
      Message 2 of 8 , Aug 1, 2004
      • 0 Attachment
        Hi,

        There is another method of capturing caps-lock (although not 100%
        foolproof)... Check it out...




        <SCRIPT LANGUAGE="JavaScript">
        function checkCapsLock( e ) {
        var myKeyCode=0;
        var myShiftKey=false;
        var myMsg='Caps Lock is On.\n\nTo prevent entering your password
        incorrectly,\nyou should press Caps Lock to turn it off.';

        // Internet Explorer 4+
        if ( document.all ) {
        myKeyCode=e.keyCode;
        myShiftKey=e.shiftKey;

        // Netscape 4
        } else if ( document.layers ) {
        myKeyCode=e.which;
        myShiftKey=( myKeyCode == 16 ) ? true : false;

        // Netscape 6
        } else if ( document.getElementById ) {
        myKeyCode=e.which;
        myShiftKey=( myKeyCode == 16 ) ? true : false;

        }

        // Upper case letters are seen without depressing the Shift key,
        therefore Caps Lock is on
        if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
        alert( myMsg );

        // Lower case letters are seen while depressing the Shift key, therefore
        Caps Lock is on
        } else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
        alert( myMsg );

        }
        }
        </script>
        <INPUT TYPE="text" onKeyPress="checkCapsLock( event )">



        Regards,
        Venkat.


        ******************************************************************

        AJ Batac <ajbatac@...> wrote:Thanks. This function will be very
        useful for login. Hope there's
        other way to warn the user that the CAPS is on even before the login
        isn't it?

        Regards,
        AJ

        On Sun, 01 Aug 2004 09:50:03 +1000, Jon Stephens <jon@...>
        wrote:
        > Unfortunately, the answer to your question is No.
        >
        > Best you can do is to check the case of what's entered, and if you get a
        > number of caps in a row, warn the user.
        >
        > document.forms[0].myTextInput.onkeypress = checkCaps;
        >
        > function checkCaps()
        > {
        >    var entered = document.forms[0].myTextInput.value;
        >
        >    if(entered.length >= 10 && entered == entered.toUpperCase())
        >        alert("Check your caps lock key, please.");
        > }
        >


        Yahoo! Groups SponsorADVERTISEMENT


        ---------------------------------
        Yahoo! Groups Links

        To visit your group on the web, go to:
        http://groups.yahoo.com/group/javascript_official/
         
        To unsubscribe from this group, send an email to:
        javascript_official-unsubscribe@yahoogroups.com
         
        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




        =====







        ___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
      • Jon Stephens
        No, there really isn t. The capslock key doesn t generate any events, there s no ASCII code or Unicode equivalent for it, and there s no event property or
        Message 3 of 8 , Aug 1, 2004
        • 0 Attachment
          No, there really isn't.

          The capslock key doesn't generate any events, there's no ASCII code or
          Unicode equivalent for it, and there's no event property or bitmask for
          it like there is for the CTRL, ALT, and SHIFT keys.

          You just have to test user input and determine whether or not it
          consists of all capitals. Sorry.

          > Date: Sun, 1 Aug 2004 15:51:12 +0800
          > From: AJ Batac <ajbatac@...>
          > Subject: Re: Re: Caps Lock
          >
          > Thanks. This function will be very useful for login. Hope there's
          > other way to warn the user that the CAPS is on even before the login
          > isn't it?
          >
          > Regards,
          > AJ
          >
          > On Sun, 01 Aug 2004 09:50:03 +1000, Jon Stephens <jon@...> wrote:
          >
          >>> Unfortunately, the answer to your question is No.
          >>>
          >>> Best you can do is to check the case of what's entered, and if you get a
          >>> number of caps in a row, warn the user.
          >>>
          >>> document.forms[0].myTextInput.onkeypress = checkCaps;
          >>>
          >>> function checkCaps()
          >>> {
          >>> var entered = document.forms[0].myTextInput.value;
          >>>
          >>> if(entered.length >= 10 && entered == entered.toUpperCase())
          >>> alert("Check your caps lock key, please.");
          >>> }
          >>>
        • Li Sheng Ng
          Jon Stephens wrote:No, there really isn t. The capslock key doesn t generate any events, there s no ASCII code or Unicode equivalent for
          Message 4 of 8 , Aug 21, 2004
          • 0 Attachment
            Jon Stephens <jon@...> wrote:No, there really isn't.

            The capslock key doesn't generate any events, there's no ASCII code or
            Unicode equivalent for it, and there's no event property or bitmask for
            it like there is for the CTRL, ALT, and SHIFT keys.

            You just have to test user input and determine whether or not it
            consists of all capitals. Sorry.

            > Date: Sun, 1 Aug 2004 15:51:12 +0800
            > From: AJ Batac
            > Subject: Re: Re: Caps Lock
            >
            > Thanks. This function will be very useful for login. Hope there's
            > other way to warn the user that the CAPS is on even before the login
            > isn't it?
            >
            > Regards,
            > AJ
            >
            > On Sun, 01 Aug 2004 09:50:03 +1000, Jon Stephens wrote:
            >
            >>> Unfortunately, the answer to your question is No.
            >>>
            >>> Best you can do is to check the case of what's entered, and if you get a
            >>> number of caps in a row, warn the user.
            >>>
            >>> document.forms[0].myTextInput.onkeypress = checkCaps;
            >>>
            >>> function checkCaps()
            >>> {
            >>> var entered = document.forms[0].myTextInput.value;
            >>>
            >>> if(entered.length >= 10 && entered == entered.toUpperCase())
            >>> alert("Check your caps lock key, please.");
            >>> }
            >>>






            Yahoo! Groups Links





            It's very simple actually. Just check if the input is in caps, and if the shift key event is there. If it is, then caps is on. There is no direct approach though.


            ---------------------------------
            ALL-NEW Yahoo! Messenger - all new features - even more fun!

            [Non-text portions of this message have been removed]
          • Jon Stephens
            I don t see where the extra step accomplishes anything more than does just checking to see if the input is in all caps.
            Message 5 of 8 , Aug 21, 2004
            • 0 Attachment
              I don't see where the extra step accomplishes anything more than does
              just checking to see if the input is in all caps.

              > Date: Sat, 21 Aug 2004 12:01:03 +0100 (BST)
              > From: Li Sheng Ng <alt3rn4tiv3@...>
              > Subject: Re: Re: Re: Caps Lock
              >
              >
              > It's very simple actually. Just check if the input is in caps, and
              > if the shift key event is there. If it is, then caps is on. There
              > is no direct approach though.
            • Li Sheng Ng
              Jon Stephens wrote: I don t see where the extra step accomplishes anything more than does just checking to see if the input is in all caps.
              Message 6 of 8 , Aug 22, 2004
              • 0 Attachment
                Jon Stephens <jon@...> wrote:
                I don't see where the extra step accomplishes anything more than does
                just checking to see if the input is in all caps.

                > Date: Sat, 21 Aug 2004 12:01:03 +0100 (BST)
                > From: Li Sheng Ng
                > Subject: Re: Re: Re: Caps Lock
                >
                >
                > It's very simple actually. Just check if the input is in caps, and
                > if the shift key event is there. If it is, then caps is on. There
                > is no direct approach though.






                Yahoo! Groups Links







                I don't either, but since the question is to detect if CAPS is on, that's the solution I propose. If the question is to detect if the input is in CAPS, then of course, that step is not necessary.


                ---------------------------------
                ALL-NEW Yahoo! Messenger - all new features - even more fun!

                [Non-text portions of this message have been removed]
              Your message has been successfully submitted and would be delivered to recipients shortly.