I was fortunate enough to turn the field type="text"into a field type="password"and return very quickly. I noticed that holding the key in the password field does not cause an accent popup and wants to take advantage of this behavior. This trick doesn't work 100% of the time, and it's an ugly hack - but it's better than nothing. Below is the complete code that I am using. I fire this on the first input field focus event.
this.disableAccentPopup = function(_input, callback){
var last_key_down = false;
var last_key_count = 0;
var keys_down = {};
var input = _input.cloneNode(true);
input.type = "password";
input.value = '';
input.focus();
_input.addEventListener("focus", function(e){
setTimeout(function(){
var t = _input.value;
var s = _input.selectionStart;
var e = _input.selectionEnd;
_input.parentNode.replaceChild(input, _input);
input.focus();
setTimeout(function(){
input.value = t;
input.type = 'input';
input.setSelectionRange(s, e);
if (callback) {
setTimeout(function(){
callback(input);
}, 0);
}
}, 0);
}, 0);
});
input.addEventListener("keydown", function(e){
keys_down[util.keyIdentifierToKeyCode(e)] = true;
if (!e.metaKey && e.keyIdentifier.substr(0,2) == "U+") {
if (last_key_down && last_key_count >= 1) {
input.type = 'input';
if (last_key_down == util.keyIdentifierToKeyCode(e)) {
e.preventDefault();
} else {
last_key_count = 0;
}
}
last_key_down = util.keyIdentifierToKeyCode(e);
last_key_count++;
}
});
input.addEventListener("keyup", function(e){
delete keys_down[util.keyIdentifierToKeyCode(e)];
if (!e.metaKey) {
if (Object.keys(keys_down).length == 0) {
last_key_down = false;
last_key_count = 0;
}
}
});
}
source
share