Fix command palette keyboard navigation (#1304)

This commit is contained in:
ZacharyZcR
2026-08-24 01:05:24 +08:00
committed by GitHub
parent 0a9086fb79
commit f1226b1f1b
4 changed files with 78 additions and 5 deletions
+20
View File
@@ -0,0 +1,20 @@
export function isShiftKey(event: Pick<KeyboardEvent, "key" | "code">) {
return (
event.key === "Shift" ||
event.code === "ShiftLeft" ||
event.code === "ShiftRight"
);
}
export function dispatchCtrlW(target: EventTarget | null) {
if (!target) return false;
const event = new KeyboardEvent("keydown", {
key: "w",
code: "KeyW",
ctrlKey: true,
bubbles: true,
cancelable: true,
});
return !target.dispatchEvent(event);
}