Add unfocus keybind
This commit is contained in:
parent
b5670d5a5b
commit
a3245059cc
|
@ -5,7 +5,8 @@ A Firefox extension adding keybinds to the Akkoma front end.
|
||||||
## Implemented keybinds:
|
## Implemented keybinds:
|
||||||
|
|
||||||
| Action | Keybind |
|
| Action | Keybind |
|
||||||
| -------------------------- | ------- |
|
| --------------------------- | ------- |
|
||||||
| Focus on compose text area | `X` |
|
| Focus on compose text area | `X` |
|
||||||
| Focus on search bar | `S` |
|
| Focus on search bar | `S` |
|
||||||
|
| Unfocus from active element | `ESC` |
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,11 @@ import type KeybindManager from "./KeybindManager";
|
||||||
|
|
||||||
import ComposeKeybind from "./keybinds/ComposeKeybind";
|
import ComposeKeybind from "./keybinds/ComposeKeybind";
|
||||||
import SearchKeybind from "./keybinds/SearchKeybind";
|
import SearchKeybind from "./keybinds/SearchKeybind";
|
||||||
|
import UnfocusKeybind from "./keybinds/UnfocusKeybind";
|
||||||
|
|
||||||
export default async function (keybindManager: KeybindManager) {
|
export default async function (keybindManager: KeybindManager) {
|
||||||
keybindManager.registerKeybind(ComposeKeybind);
|
keybindManager.registerKeybind(ComposeKeybind);
|
||||||
keybindManager.registerKeybind(SearchKeybind);
|
keybindManager.registerKeybind(SearchKeybind);
|
||||||
|
keybindManager.registerKeybind(UnfocusKeybind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue