Add unfocus keybind
This commit is contained in:
parent
b5670d5a5b
commit
a3245059cc
|
@ -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` |
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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