From d18b34f2d98f5099625b5dc42eca09157edb4bb1 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 13 May 2017 15:24:41 -0700 Subject: [PATCH] bind_box_to_button can use ctrl+enter --- frontends/etiquette_flask/static/common.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontends/etiquette_flask/static/common.js b/frontends/etiquette_flask/static/common.js index 487a9c0..59e3140 100644 --- a/frontends/etiquette_flask/static/common.js +++ b/frontends/etiquette_flask/static/common.js @@ -43,15 +43,21 @@ function post(url, data, callback) request.send(data); } -function bind_box_to_button(box, button) +function bind_box_to_button(box, button, ctrl_enter) { box.onkeydown=function() { - if (event.keyCode == 13) + // Thanks Yaroslav Yakovlev + // http://stackoverflow.com/a/9343095 + if ( + (event.keyCode == 13 || event.keyCode == 10) && + ((ctrl_enter && event.ctrlKey) || (!ctrl_enter)) + ) { button.click(); } }; + } function entry_with_history_hook(box, button) {