cleanup key handling
This commit is contained in:
parent
a6a7ace10d
commit
7b2ddf13c3
1 changed files with 6 additions and 17 deletions
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue