Skip to content

Commit a8bfcee

Browse files
Copilothaslinghuis
andcommitted
Add Enter key support for single-choice information dialogs
Co-authored-by: haslinghuis <[email protected]>
1 parent ee6dac4 commit a8bfcee

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/js/gui.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,21 @@ class GuiControl {
381381

382382
buttonConfirm.off("click");
383383

384-
buttonConfirm.on("click", () => {
384+
const confirmAction = () => {
385385
dialog[0].close();
386+
dialog.off("keydown");
386387
resolve();
388+
};
389+
390+
buttonConfirm.on("click", confirmAction);
391+
392+
// Add Enter key support for single-choice dialog
393+
dialog.off("keydown");
394+
dialog.on("keydown", (e) => {
395+
if (e.key === "Enter") {
396+
e.preventDefault();
397+
confirmAction();
398+
}
387399
});
388400

389401
dialog[0].showModal();

0 commit comments

Comments
 (0)