diff --git a/core/java/android/text/method/QwertyKeyListener.java b/core/java/android/text/method/QwertyKeyListener.java index b4a1e8cfe9434..c43864d0f215e 100644 --- a/core/java/android/text/method/QwertyKeyListener.java +++ b/core/java/android/text/method/QwertyKeyListener.java @@ -360,6 +360,15 @@ public class QwertyKeyListener extends BaseKeyListener { return super.onKeyDown(view, content, keyCode, event); } + return true; + } + } else if (keyCode == KeyEvent.KEYCODE_ESCAPE && event.hasNoModifiers()) { + // If user is in the process of composing with a dead key, and + // presses Escape, cancel it. We need special handling because + // the Escape key will not produce a Unicode character + if (activeStart == selStart && activeEnd == selEnd) { + Selection.setSelection(content, selEnd); + content.removeSpan(TextKeyListener.ACTIVE); return true; } }