Prompts can be closed by keyboard: Enter emulates the default button click, Escape the cancel action.
This commit is contained in:
parent
5aeb7f3c75
commit
2b0c9e87bf
|
@ -115,6 +115,19 @@
|
|||
b.addEventListener("click", buttonClicked);
|
||||
}
|
||||
|
||||
addEventListener("keydown", e => {
|
||||
if (e.ctrlKey || e.metaKey || e.shiftKey) return;
|
||||
switch(e.code) {
|
||||
case "Escape":
|
||||
window.close();
|
||||
return;
|
||||
case "Enter":
|
||||
let defButton = document.querySelector("#buttons button[type=submit]");
|
||||
if (defButton) defButton.click();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
let resize = async e => {
|
||||
if (!("windows" in browser)) {
|
||||
// tabbed (mobile?) - ensure buttons are visible
|
||||
|
|
Loading…
Reference in New Issue