Prechádzať zdrojové kódy

feat: add event listener to close modal with esc

Corentin NELHOMME 1 rok pred
rodič
commit
46e25a15cc
1 zmenil súbory, kde vykonal 7 pridanie a 0 odobranie
  1. 7 0
      index.js

+ 7 - 0
index.js

@@ -1084,6 +1084,11 @@ let NEWSITEEDITOR = (function () {
         const info = videoInfos.get(currentId);
 
         showModal();
+        document.body.addEventListener('keyup', (e) => {
+          if(e.code === "Escape") {
+            hideModal();
+          }
+        })
         posterPreview.src = info.poster;
         videoPreview.src = info.src;
       });
@@ -1125,6 +1130,8 @@ let NEWSITEEDITOR = (function () {
         .addEventListener("click", () => {
           submitModal();
         });
+
+      
     }
 
     //Récuperer les infos des vidéos