From ca0c3ad11acd71178564739a2596f0c849913545 Mon Sep 17 00:00:00 2001 From: p-sam Date: Fri, 24 Jan 2020 14:19:12 +0100 Subject: [PATCH] Catch the enter keypress event before submit Fixes #54 --- lib/page/prompt.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/page/prompt.js b/lib/page/prompt.js index ed93ebb..3dfd1ba 100644 --- a/lib/page/prompt.js +++ b/lib/page/prompt.js @@ -104,14 +104,17 @@ docReady(() => { } dataEl.addEventListener('keyup', e => { - if (e.key === 'Enter') { - promptSubmit(); - } - if (e.key === 'Escape') { promptCancel(); } }); + + dataEl.addEventListener('keypress', e => { + if (e.key === 'Enter') { + e.preventDefault(); + promptSubmit(); + } + }); } else if (promptOptions.type === 'select') { dataEl = document.createElement('select'); let optionEl;