diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 29dc8b4a..744fe4e5 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -92,7 +92,7 @@ var TextInput = function(parentNode, host) { }, 0); }; - var onKeyPress = function(e) { + var onPropertyChange = function(e) { if (useragent.isIE && text.value.charCodeAt(0) > 128) return; setTimeout(function() { if (!inCompostion) @@ -155,22 +155,11 @@ var TextInput = function(parentNode, host) { inCompostion ? onCompositionUpdate() : onCompositionStart(); }); }; - - if (text.attachEvent) { - // Old IE + Opera - event.addListener(text, "propertychange", onKeyPress); - } - else { - if (useragent.isChrome || useragent.isSafari) - event.addListener(text, "textInput", onTextInput); - else if (useragent.isIE) - // IE9 - event.addListener(text, "textinput", onTextInput); - else - // All browsers except old IE - event.addListener(text, "input", onTextInput); - } + if ("onpropertychange" in text && !("oninput" in text)) + event.addListener(text, "propertychange", onPropertyChange); + else + event.addListener(text, "input", onTextInput); event.addListener(text, "paste", function(e) { // Mark that the next input text comes from past. @@ -184,7 +173,7 @@ var TextInput = function(parentNode, host) { else { // If a browser doesn't support any of the things above, use the regular // method to detect the pasted input. - onKeyPress(); + onPropertyChange(); } });