Implement search keybind
This commit is contained in:
parent
37d4d377e4
commit
262e871ca3
|
@ -1,8 +1,10 @@
|
|||
import type KeybindManager from "./KeybindManager";
|
||||
|
||||
import ComposeKeybind from "./keybinds/ComposeKeybind";
|
||||
import SearchKeybind from "./keybinds/SearchKeybind";
|
||||
|
||||
export default async function (keybindManager: KeybindManager) {
|
||||
keybindManager.registerKeybind(ComposeKeybind);
|
||||
keybindManager.registerKeybind(SearchKeybind);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import type { Keybind } from "../KeybindManager";
|
||||
|
||||
const keybind: Keybind = {
|
||||
key: "s",
|
||||
|
||||
execute: function () {
|
||||
const buttonElement = document.querySelector(
|
||||
"button.nav-icon:nth-child(1)"
|
||||
);
|
||||
|
||||
if (!buttonElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
const button = buttonElement as HTMLElement;
|
||||
|
||||
button.click();
|
||||
|
||||
const inputElement = document.querySelector("#search-bar-input");
|
||||
|
||||
if (!inputElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
const input = inputElement as HTMLElement;
|
||||
|
||||
input.focus();
|
||||
},
|
||||
};
|
||||
|
||||
export default keybind;
|
||||
|
Loading…
Reference in New Issue