Page 1 of 1

Show Caps Lock status on HTML5 client logon

Posted: Thu Jun 17, 2021 3:12 pm
by bblsystems
We have users trigger the bruteforce lockout due to bad passwords, and often it's because the caps lock is on.

Maybe you could display a "CAPS Lock is ON" below the password field if caps lock is on.

The Windows logon page will display such a message to help users.

Here's how to display a caps lock status via javascript.

https://stackoverflow.com/a/348802/5216

I guess we could just add it to our logon pages ourselves using that technique, but others might benefit it the default config had that.

Re: Show Caps Lock status on HTML5 client logon

Posted: Sat Jun 19, 2021 5:06 pm
by juwagn
Hello,

it hasn't anything to do directly with html5 client logon but is the portal functionality common for native client and html5 client.
For our portal developers following could be useful.

Code: Select all

  (function() {
    var reg = 0, caps = false;

    var isCaps = function(a) {
      if(a) {
        alert("caps is pressed");
      }
    };

    document.addEventListener('keydown', function(evt) {
      if(reg == 0) {
        if(!evt.getModifierState) {
          reg = 1;

          document.addEventListener('keypress', function(e) {
            e = e || window.event;
            var s = String.fromCharCode(e.which || e.keyCode);
            if(s.toUpperCase() !== s.toLowerCase()) {
              isCaps(((s.toUpperCase() === s) && !e.shiftKey) || ((s.toLowerCase() === s) && e.shiftKey)); 
            } //undetectable char pressed
          });
        } else { reg = 2; }
      }
      if(reg == 2) { isCaps(evt.getModifierState('CapsLock')); }
    });
  })();
Sincerely yours, JW.