Add unfocus keybind

This commit is contained in:
Violet Millie 2024-01-26 19:01:30 +00:00
parent b5670d5a5b
commit a3245059cc
3 changed files with 27 additions and 4 deletions

View File

@ -4,8 +4,9 @@ A Firefox extension adding keybinds to the Akkoma front end.
## Implemented keybinds:
| Action | Keybind |
| -------------------------- | ------- |
| Focus on compose text area | `X` |
| Focus on search bar | `S` |
| Action | Keybind |
| --------------------------- | ------- |
| Focus on compose text area | `X` |
| Focus on search bar | `S` |
| Unfocus from active element | `ESC` |

View File

@ -2,9 +2,11 @@ import type KeybindManager from "./KeybindManager";
import ComposeKeybind from "./keybinds/ComposeKeybind";
import SearchKeybind from "./keybinds/SearchKeybind";
import UnfocusKeybind from "./keybinds/UnfocusKeybind";
export default async function (keybindManager: KeybindManager) {
keybindManager.registerKeybind(ComposeKeybind);
keybindManager.registerKeybind(SearchKeybind);
keybindManager.registerKeybind(UnfocusKeybind);
}

View File

@ -0,0 +1,20 @@
import type { Keybind } from "../KeybindManager";
const keybind: Keybind = {
key: "Escape",
allowWhileComposing: true,
execute: function () {
const activeElement = document.activeElement as HTMLElement;
if (!activeElement) {
return;
}
activeElement.blur();
},
};
export default keybind;