feat: add shortcuts display

This commit is contained in:
syntaxbullet
2026-07-03 23:44:24 +02:00
parent cbd4eb5e9b
commit e5c7f09cea
4 changed files with 108 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ export {
export type { CommandKeybind, GlobalKeybindConsumer, Keybind, KeybindEvent, KeybindMap } from "./keyboard";
export { handleKeybind, keybindFromEvent } from "./keyboard";
export { handleHistoryKey } from "./history";
export { handleToolKey } from "./tool-keybinds";
export { findGroup, findLayerInfoInDocument, handleDeleteSelectionKey, resolveLayerDrop } from "./layers-panel";
export type { LayerDropTarget, LayerInfo } from "./layers-panel";
export { handleArtboardSelection } from "./selection";

20
input/tool-keybinds.ts Normal file
View File

@@ -0,0 +1,20 @@
import { commandIds } from "@commands/ids";
import type { Dispatch } from "@commands/dispatcher";
import type { KeybindEvent } from "./keyboard";
const toolKeybinds = {
b: "brush",
e: "eraser",
p: "pan",
s: "select",
} as const;
export function handleToolKey(options: { event: KeybindEvent; dispatch: Dispatch }): boolean {
if (options.event.altKey || options.event.ctrlKey || options.event.metaKey) return false;
const tool = toolKeybinds[options.event.key.toLowerCase() as keyof typeof toolKeybinds];
if (!tool) return false;
options.dispatch(commandIds.toolSetActive, { tool });
return true;
}