From 88f77b8ccad5a723814358d903eabf600345e389 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 25 Oct 2021 21:31:27 +0200 Subject: [PATCH] spacebar as actionkey when ok/cancel focused --- copyparty/web/util.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 54878cfd..63448db0 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -1057,15 +1057,22 @@ var modal = (function () { } function onkey(e) { - if (e.code == 'Enter') { - var a = ebi('modal-ng'); - if (a && document.activeElement == a) + var k = e.code, + eok = ebi('modal-ok'), + eng = ebi('modal-ng'), + ae = document.activeElement; + + if (k == 'Space' && ae && (ae === eok || ae === eng)) + k = 'Enter'; + + if (k == 'Enter') { + if (ae && ae == eng) return ng(); return ok(); } - if (e.code == 'Escape') + if (k == 'Escape') return ng(); }