bind_box_to_button can use ctrl+enter

This commit is contained in:
voussoir 2017-05-13 15:24:41 -07:00
parent 55c14f3844
commit d18b34f2d9

View file

@ -43,15 +43,21 @@ function post(url, data, callback)
request.send(data); request.send(data);
} }
function bind_box_to_button(box, button) function bind_box_to_button(box, button, ctrl_enter)
{ {
box.onkeydown=function() 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(); button.click();
} }
}; };
} }
function entry_with_history_hook(box, button) function entry_with_history_hook(box, button)
{ {