From 959de82e2a3176425b2b8924ebc919312ba5f5de Mon Sep 17 00:00:00 2001
From: joassouza <joassouzasantos@gmail.com>
Date: Thu, 29 Oct 2015 14:54:21 -0300
Subject: [PATCH] Allow plugins handle "esc" key event

---
 src/static/js/ace2_inner.js | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index d912dfb1..f02e888c 100644
--- a/src/static/js/ace2_inner.js
+++ b/src/static/js/ace2_inner.js
@@ -3641,12 +3641,6 @@ function Ace2Inner(){
     var altKey = evt.altKey;
     var shiftKey = evt.shiftKey;
 
-    // prevent ESC key
-    if (keyCode == 27)
-    {
-      evt.preventDefault();
-      return;
-    }
     // Is caret potentially hidden by the chat button?
     var myselection = document.getSelection(); // get the current caret selection
     var caretOffsetTop = myselection.focusNode.parentNode.offsetTop | myselection.focusNode.offsetTop; // get the carets selection offset in px IE 214
@@ -3839,6 +3833,15 @@ function Ace2Inner(){
           }, 0);
           specialHandled = true;
         }
+        if ((!specialHandled) && isTypeForSpecialKey && keyCode == 27)
+        {
+          // prevent esc key;
+          // in mozilla versions 14-19 avoid reconnecting pad.
+
+          fastIncorp(4);
+          evt.preventDefault();
+          specialHandled = true;
+        }
         if ((!specialHandled) && isTypeForCmdKey && String.fromCharCode(which).toLowerCase() == "s" && (evt.metaKey || evt.ctrlKey) && !evt.altKey) /* Do a saved revision on ctrl S */
         {
           evt.preventDefault();