feat: add shortcuts display
This commit is contained in:
@@ -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
20
input/tool-keybinds.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user