While using the Google virtual keyboard and setting it on a textarea, I noticed an issue. When I type something in the textarea, two characters are printed - one uppercase and one lowercase.
To address this problem, I wrote a JavaScript function for the textarea. This function automatically capitalizes the letters after a dot "." is typed.
Now, I am trying to figure out how to remove one character so that only one character is printed in the textarea. Currently, every time I press a single key, two characters are printed. I have set up a keypress event on the textarea to handle this function.
function caps(e, textarea, value){
var unicode = e.keyCode ? e.keyCode : e.charCode;
var str = value.trim();
str = str.charAt(str.length - 1);
if((str == "." || value.length == 0) && (unicode >= 97 && unicode <= 122)){
textarea.value = textarea.value + String.fromCharCode(unicode).toUpperCase();
return false;
}
return true;
}