Skip to content Skip to sidebar Skip to footer

How Do I Turn On/off The Caps Lock Key

We can able to detect the Caps lock key is ON/OFF using Jquery. My question is 'can we possible to Turn ON/OFF the Caps lock key using Jquery or Javascript in Keypress event'. And

Solution 1:

You can't change whether the caps lock key is on or off. You can however change whether your input strings are lower or upper case with Javascript based on whether the caps lock key is on or off.

for (char in inputString) {
    if(capslock) { // do your caps lock detection hereif(char === char.toUpperCase()) { // it's upper casechar = char.toLowerCase();
        } else {
            char = char.toUpperCase();
        }
    }
}

Solution 2:

You can't do this jquery like javascript will be sandboxed inside the browser.

Solution 3:

Detection only:

$('#id').keypress(function(e) { 
    var s = String.fromCharCode( e.which );
    if ( s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey ) {
        alert('caps is on');
    }
});

Solution 4:

If this would be possible, then I would be able to control user's sound volume, or maybe check what he have in hard disk, I may be more curious and spy his network card traffic...I would own the world with a simple JavaScript file :)

Post a Comment for "How Do I Turn On/off The Caps Lock Key"