Question

I don't really like people who write with Caps Lock. In addition the aversion, it defaces the whole application. I am wondering how to prevent users writing all characters with caps lock. I cannot force all text to lowercase due to special names and abbreviations. What logic should I use?

Was it helpful?

Solution

Politely decline their posts—explaining why—if the number of capital letter exceeds the number of lowercase letters by more than 30, say.

Don't implement this on a FORTRAN forum

OTHER TIPS

You could check how many upper case characters are in a word, then limit that. Someone above has given the example of names like 'McLaren', this way would allow that. the down side is, if you put the maximum on 3, 'LOL' would stil be possible. The way to go would be to take the length of the word 'McLaren' would be 7 then cap it on a percentage like 20%, this enables longer words to have more uppercase characters, but not be all caps. (nothing will completely prevent it, but this will make it harder for them.)

Fun fact, today is international caps-lock day. :)

keypress: function(e) {
    var ev = e ? e : window.event;
    if (!ev) {
        return;
    }
    var targ = ev.target ? ev.target : ev.srcElement;
    // get key pressed
    var which = -1;
    if (ev.which) {
        which = ev.which;
    } else if (ev.keyCode) {
        which = ev.keyCode;
    }
    // get shift status
    var shift_status = false;
    if (ev.shiftKey) {
        shift_status = ev.shiftKey;
    } else if (ev.modifiers) {
        shift_status = !!(ev.modifiers & 4);
    }

    // At this point, you have the ASCII code in "which", 
    // and shift_status is true if the shift key is pressed
}

Source --http://24ways.org/2007/capturing-caps-lock

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top