Skip to content

Commit

Permalink
feature: add ability to submit even while in markdown input using ctr…
Browse files Browse the repository at this point in the history
…l/cmd + enter
  • Loading branch information
thesephist committed May 31, 2019
1 parent 06f4090 commit b057553
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions static/js/main.js
Expand Up @@ -10,6 +10,10 @@
requiredMessage.style.display = displayed ? '' : 'none';
}

function submitForm() {
document.querySelector('form').submit();
}

async function checkIfShouldShowPasswordRequired() {
const id = idInput.value;
if (id) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b057553

Please sign in to comment.