diff --git a/front_end/static/js/popup.js b/front_end/static/js/popup.js
index a37245225376a8b6ba33bd38c5af54a3633c0784..7afff7f91ad1a1b74b223630f0d219cfba4eb0cb 100644
--- a/front_end/static/js/popup.js
+++ b/front_end/static/js/popup.js
@@ -37,4 +37,19 @@ function createNewTabLink(imageUrl) {
     button.textContent = 'View in New Tab';
     button.classList.add('dialog-button');
     return button;
-}
\ No newline at end of file
+}
+
+document.onkeydown = function(evt) {
+    evt = evt || window.event;
+    var isEscape = false;
+    if ("key" in evt) {
+        isEscape = (evt.key === "Escape" || evt.key === "Esc");
+    } else {
+        isEscape = (evt.keyCode === 27);
+    }
+    if (isEscape) {
+        while (dialog.hasChildNodes()) {
+            dialog.removeChild(dialog.firstChild);
+        }
+    }
+};
\ No newline at end of file