From b05755300a51689abcb739d06397e6e8bc7ec8be Mon Sep 17 00:00:00 2001 From: Linus Lee Date: Fri, 31 May 2019 02:35:40 -0700 Subject: [PATCH] feature: add ability to submit even while in markdown input using ctrl/cmd + enter --- static/js/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/static/js/main.js b/static/js/main.js index b606e53..1a78bd5 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -10,6 +10,10 @@ requiredMessage.style.display = displayed ? '' : 'none'; } + function submitForm() { + document.querySelector('form').submit(); + } + async function checkIfShouldShowPasswordRequired() { const id = idInput.value; if (id) { @@ -73,6 +77,11 @@ evt.target.setSelectionRange(idx + 4, idx + 4); } } + + // metaKey detects the command key on macOS + if (evt.key === 'Enter' && (evt.ctrlKey || evt.metaKey)) { + submitForm(); + } } function debounce(fn, duration) {