From a329ff026ea3e33ea09bc8d833e6614b6df3de76 2011-11-24 01:58:21
From: Matthias BUSSONNIER <bussonniermatthias@gmail.com>
Date: 2011-11-24 01:58:21
Subject: [PATCH] Intercept <esc> avoid closing websocket on Firefox

Closes #1031; closes #1032 (rebased and fixed tiny typo)

---

diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js
index 108f4c9..a50dcb3 100644
--- a/IPython/frontend/html/notebook/static/js/notebook.js
+++ b/IPython/frontend/html/notebook/static/js/notebook.js
@@ -57,6 +57,11 @@ var IPython = (function (IPython) {
         $(document).keydown(function (event) {
             // console.log(event);
             if (that.read_only) return;
+            if (event.which === 27) {
+                // Intercept escape at highest level to avoid closing 
+                // websocket connection with firefox
+                event.preventDefault();
+            }
             if (event.which === 38) {
                 var cell = that.selected_cell();
                 if (cell.at_top()) {